Skip to content

Commit

Permalink
Log timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Oct 11, 2023
1 parent 6c1af31 commit 541eff7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'

// JDA
implementation 'net.dv8tion:JDA:5.0.0-beta.10'
implementation 'net.dv8tion:JDA:5.0.0-beta.15'
implementation 'pw.chew:jda-chewtils:2.0-SNAPSHOT'

// Logging
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/geysermc/discordbot/listeners/LogHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.audit.ActionType;
import net.dv8tion.jda.api.audit.AuditLogChange;
import net.dv8tion.jda.api.audit.AuditLogEntry;
import net.dv8tion.jda.api.audit.AuditLogKey;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Invite;
import net.dv8tion.jda.api.entities.Message;
Expand Down Expand Up @@ -137,6 +139,16 @@ public void onGuildAuditLogEntryCreate(@NotNull GuildAuditLogEntryCreateEvent ev
actionTitle = "Kicked user";
color = BotColors.SUCCESS.getColor();
}
case MEMBER_UPDATE -> {
AuditLogChange timeoutChange = event.getEntry().getChangeByKey(AuditLogKey.MEMBER_TIME_OUT);
if (timeoutChange != null && timeoutChange.getNewValue() != null) {
action = "timeout";
actionTitle = "Timed out user until " + TimeFormat.DATE_TIME_SHORT.atInstant(Instant.parse(timeoutChange.getNewValue()));
color = BotColors.SUCCESS.getColor();
} else {
return;
}
}
default -> {
return;
}
Expand Down

0 comments on commit 541eff7

Please sign in to comment.