Skip to content

Commit 79d1d09

Browse files
committed
Added extra logging to Ban handler in attempt to catch bugs
1 parent e6c8c75 commit 79d1d09

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- Document properties -->
99
<groupId>com.ibdiscord</groupId>
1010
<artifactId>IB.ai</artifactId>
11-
<version>4.1.49</version>
11+
<version>4.1.50</version>
1212

1313
<name>IB.ai</name>
1414
<url>http://www.ibdiscord.com</url>

src/main/java/com/ibdiscord/listeners/GuildListener.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public void onGuildMemberJoin(GuildMemberJoinEvent event) {
109109
@Override
110110
public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
111111
updateHelperMessages(event.getGuild(), event.getMember().getRoles());
112+
IBai.INSTANCE.getLogger().info("Looking for Kick or Ban for user: '{}'", event.getMember().getUser().getIdLong());
112113
queryAuditLog(event.getGuild(), event.getMember().getUser().getIdLong(), ActionType.BAN, ActionType.KICK);
113114
Gravity gravity = DataContainer.INSTANCE.getGravity();
114115
RoleData roleData = gravity.load(new RoleData(event.getGuild().getId(), event.getMember().getUser().getId()));
@@ -157,6 +158,7 @@ private void queryAuditLog(Guild guild, long target, ActionType... actionTypes)
157158
synchronized(mutex) {
158159
guild.retrieveAuditLogs().limit(10).queue(entries -> {
159160
if(entries.isEmpty()) {
161+
IBai.INSTANCE.getLogger().info("No audit logs retrieved.");
160162
return;
161163
}
162164

@@ -165,7 +167,7 @@ private void queryAuditLog(Guild guild, long target, ActionType... actionTypes)
165167
&& latest.getTargetType() == TargetType.MEMBER
166168
&& latest.getTargetIdLong() == target) {
167169

168-
IBai.INSTANCE.getLogger().info("Latest audit log: type '{}', target type '{}', target id '{}', "
170+
IBai.INSTANCE.getLogger().info("Found audit log: type '{}', target type '{}', target id '{}', "
169171
+ "user {}, options {}",
170172
latest.getType(),
171173
latest.getTargetType(),
@@ -178,6 +180,7 @@ private void queryAuditLog(Guild guild, long target, ActionType... actionTypes)
178180
String reason = latest.getReason();
179181
if(user == null
180182
|| staff == null) {
183+
IBai.INSTANCE.getLogger().info("User or Staff is null");
181184
throw new RuntimeException("user/staff nil");
182185
}
183186
boolean redacted = false;
@@ -229,6 +232,7 @@ private void queryAuditLog(Guild guild, long target, ActionType... actionTypes)
229232
}
230233
break;
231234
case BAN:
235+
IBai.INSTANCE.getLogger().info("Handling Ban");
232236
punishment.setType(PunishmentType.BAN);
233237
handler.onPunish();
234238
break;
@@ -239,15 +243,16 @@ private void queryAuditLog(Guild guild, long target, ActionType... actionTypes)
239243
default:
240244
break;
241245
}
246+
}, error -> {
247+
IBai.INSTANCE.getLogger().info("Could not retrieve user.");
248+
IBai.INSTANCE.getLogger().info(error.getMessage());
242249
});
243250
break;
244251
}
245252
}
246-
247-
248253
}, error -> {
249-
IBai.INSTANCE.getLogger().info("Blimey, there's been an error.");
250-
error.printStackTrace();
254+
IBai.INSTANCE.getLogger().info("Blimey, there's been an error in the audit log.");
255+
IBai.INSTANCE.getLogger().error(error.getMessage());
251256
}
252257
);
253258
}

0 commit comments

Comments
 (0)