diff --git a/src/main/java/org/geysermc/discordbot/listeners/AutoModHandler.java b/src/main/java/org/geysermc/discordbot/listeners/AutoModHandler.java index 48720d8f..bc3aa30f 100644 --- a/src/main/java/org/geysermc/discordbot/listeners/AutoModHandler.java +++ b/src/main/java/org/geysermc/discordbot/listeners/AutoModHandler.java @@ -28,6 +28,7 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.User; @@ -70,35 +71,45 @@ public void onAutoModExecution(@Nonnull AutoModExecutionEvent event) { Member member = event.getGuild().getMemberById(userId); if (member == null || member.isTimedOut()) return; - event.getGuild().timeoutFor(member, 7, TimeUnit.DAYS).queue(); + Guild guild = event.getGuild(); + String reason = "Suspected account compromise"; User user = member.getUser(); user.openPrivateChannel().queue((channel) -> { MessageEmbed embed = new EmbedBuilder() - .setTitle("You have been automatically timed out in " + event.getGuild().getName() + "!") - .addField("Reason", "Suspected account compromise", false) - .addField("Duration", "7 days", false) + .setTitle("You have been automatically kicked from " + guild.getName() + "!") + .addField("Reason", reason, false) .addField("Recommended Actions", "Change your Discord password, enable 2FA, and scan your computer for malware. See [Discord's article](https://support.discord.com/hc/en-us/articles/24160905919511-My-Discord-Account-was-Hacked-or-Compromised) for more info.", false) .setTimestamp(Instant.now()) .setColor(BotColors.WARNING.getColor()) .build(); - - channel.sendMessageEmbeds(embed).queue(); + + channel.sendMessageEmbeds(embed).queue(message -> { + // Kick user + guild.kick(user).reason(reason).queue(); + }, throwable -> { + // Kick user + guild.kick(user).reason(reason).queue(); + }); + }, throwable -> { + // Kick user + guild.kick(member).reason(reason).queue(); }); - Member selfMember = event.getGuild().getSelfMember(); - int id = GeyserBot.storageManager.addLog(selfMember, "timeout", user, "Suspected account compromise"); + + Member selfMember = guild.getSelfMember(); + int id = GeyserBot.storageManager.addLog(selfMember, "kick", user, reason); MessageEmbed logEmbed = new EmbedBuilder() - .setTitle("Timed out user") + .setTitle("Kicked user") .addField("User", user.getAsMention(), false) .addField("Staff member", selfMember.getAsMention(), false) - .addField("Reason", "Suspected account compromise", false) + .addField("Reason", reason, false) .setFooter("ID: " + id) .setTimestamp(Instant.now()) .setColor(BotColors.WARNING.getColor()) .build(); - ServerSettings.getLogChannel(event.getGuild()).sendMessageEmbeds(logEmbed).queue(); + ServerSettings.getLogChannel(guild).sendMessageEmbeds(logEmbed).queue(); } }