From 541eff783a0a3caa4de0644f1fcfdc8e77fbc41f Mon Sep 17 00:00:00 2001 From: rtm516 Date: Wed, 11 Oct 2023 21:39:43 +0100 Subject: [PATCH] Log timeouts --- build.gradle | 2 +- .../geysermc/discordbot/listeners/LogHandler.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e6ae381c..67699c2e 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/src/main/java/org/geysermc/discordbot/listeners/LogHandler.java b/src/main/java/org/geysermc/discordbot/listeners/LogHandler.java index 8a8f43aa..f7ea95c8 100644 --- a/src/main/java/org/geysermc/discordbot/listeners/LogHandler.java +++ b/src/main/java/org/geysermc/discordbot/listeners/LogHandler.java @@ -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; @@ -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; }