From b3c419f97f13812846459f58229bfdd1bdcea8f1 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Fri, 21 Oct 2022 16:31:51 +0530 Subject: [PATCH 1/8] enhanced mod aciton dm message --- .../tjbot/commands/moderation/BanCommand.java | 31 ++--- .../commands/moderation/KickCommand.java | 29 ++--- .../commands/moderation/ModerationUtils.java | 108 +++++++++--------- .../commands/moderation/MuteCommand.java | 25 ++-- .../moderation/QuarantineCommand.java | 23 ++-- .../commands/moderation/UnmuteCommand.java | 22 ++-- .../moderation/UnquarantineCommand.java | 22 ++-- .../commands/moderation/WarnCommand.java | 19 ++- 8 files changed, 125 insertions(+), 154 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java index 751c15679e..50171102f2 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java @@ -2,7 +2,6 @@ import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.events.GenericEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.exceptions.ErrorResponseException; import net.dv8tion.jda.api.interactions.InteractionHook; @@ -13,7 +12,6 @@ import net.dv8tion.jda.api.requests.ErrorResponse; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; -import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +43,7 @@ public final class BanCommand extends SlashCommandAdapter { private static final String REASON_OPTION = "reason"; private static final String COMMAND_NAME = "ban"; private static final String ACTION_VERB = "ban"; + private static final String ACTION_TITLE = "Ban"; @SuppressWarnings("StaticCollection") private static final List DURATIONS = List.of(ModerationUtils.PERMANENT_DURATION, "1 hour", "3 hours", "1 day", "2 days", "3 days", "7 days", "30 days"); @@ -83,24 +82,14 @@ private static RestAction handleAlreadyBanned(Guild.Ban ban, return event.reply(message).setEphemeral(true); } - private static RestAction sendDm(ISnowflake target, - @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild, - GenericEvent event) { - String durationMessage = - temporaryData == null ? "permanently" : "for " + temporaryData.duration(); - String dmMessage = - """ - Hey there, sorry to tell you but unfortunately you have been banned %s from the server %s. - If you think this was a mistake, please contact a moderator or admin of the server. - The reason for the ban is: %s - """ - .formatted(durationMessage, guild.getName(), reason); - - return event.getJDA() - .openPrivateChannelById(target.getId()) - .flatMap(channel -> channel.sendMessage(dmMessage)) - .mapToResult() - .map(Result::isSuccess); + private static RestAction sendDm(User target, + @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild) { + String durationMessage = temporaryData == null ? "Permanently" : temporaryData.duration(); + String description = + "Hey there, sorry to tell you but unfortunately you have been banned from the server."; + + return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild, + ACTION_TITLE, description, reason, durationMessage), target); } private static MessageEmbed sendFeedback(boolean hasSentDm, User target, Member author, @@ -141,7 +130,7 @@ private static Optional> handleNotAlreadyBannedRespo private RestAction banUserFlow(User target, Member author, @Nullable ModerationUtils.TemporaryData temporaryData, String reason, int deleteHistoryDays, Guild guild, SlashCommandInteractionEvent event) { - return sendDm(target, temporaryData, reason, guild, event) + return sendDm(target, temporaryData, reason, guild) .flatMap(hasSentDm -> banUser(target, author, temporaryData, reason, deleteHistoryDays, guild).map(banResult -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, temporaryData, reason)) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java index 696476a3e6..e775ad368c 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java @@ -1,17 +1,12 @@ package org.togetherjava.tjbot.commands.moderation; import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.ISnowflake; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.MessageEmbed; -import net.dv8tion.jda.api.events.GenericEvent; +import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; -import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +31,7 @@ public final class KickCommand extends SlashCommandAdapter { private static final String REASON_OPTION = "reason"; private static final String COMMAND_NAME = "kick"; private static final String ACTION_VERB = "kick"; + private static final String ACTION_TITLE = "Kick"; private final ModerationActionsStore actionsStore; /** @@ -60,7 +56,7 @@ private static void handleAbsentTarget(IReplyCallback event) { private void kickUserFlow(Member target, Member author, String reason, Guild guild, SlashCommandInteractionEvent event) { - sendDm(target, reason, guild, event) + sendDm(target.getUser(), reason, guild) .flatMap(hasSentDm -> kickUser(target, author, reason, guild) .map(kickResult -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason)) @@ -68,19 +64,12 @@ private void kickUserFlow(Member target, Member author, String reason, Guild gui .queue(); } - private static RestAction sendDm(ISnowflake target, String reason, Guild guild, - GenericEvent event) { - return event.getJDA() - .openPrivateChannelById(target.getId()) - .flatMap(channel -> channel.sendMessage( - """ - Hey there, sorry to tell you but unfortunately you have been kicked from the server %s. - If you think this was a mistake, please contact a moderator or admin of the server. - The reason for the kick is: %s - """ - .formatted(guild.getName(), reason))) - .mapToResult() - .map(Result::isSuccess); + private static RestAction sendDm(User target, String reason, Guild guild) { + String description = "Hey there, sorry to tell you but unfortunately you have been kicked"; + + return ModerationUtils.sendModActionDm( + ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, true), + target); } private AuditableRestAction kickUser(Member target, Member author, String reason, diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java index b4877fc0e5..3c550577ae 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java @@ -3,10 +3,10 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel; import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; +import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,8 +23,8 @@ import java.util.EnumSet; import java.util.Optional; import java.util.Set; +import java.util.function.Function; import java.util.function.Predicate; -import java.util.function.UnaryOperator; import java.util.regex.Pattern; /** @@ -69,8 +69,6 @@ private ModerationUtils() { private static final Set SOFT_ACTIONS = EnumSet.of(ModerationAction.WARN, ModerationAction.QUARANTINE); - - /** * Checks whether the given reason is valid. If not, it will handle the situation and respond to * the user. @@ -390,64 +388,66 @@ static Optional computeTemporaryData(String durationText) { } /** - * Wrapper to hold data relevant to temporary actions, for example the time it expires. + * Creates a nice looking embed for the mod action taken. * - * @param expiresAt the time the temporary action expires - * @param duration a human-readable text representing the duration of the temporary action, such - * as {@code "1 day"}. + * @param guild the guild in which the action has been taken + * @param actionTitle the mod action itself e.g, Ban + * @param description a short description explaining the action + * @param reason reason for the action taken + * @param isPunishAction is it a punish action e.g. ban, warn + * @return the embed */ - record TemporaryData(Instant expiresAt, String duration) { + static RestAction getModActionEmbed(Guild guild, String actionTitle, + String description, String reason, boolean isPunishAction) { + Function embedBuilder = commandMention -> new EmbedBuilder() + .setAuthor(guild.getName(), null, guild.getIconUrl()) + .setTitle(actionTitle) + .setDescription(description + + "\n\nTo get in touch with a moderator, you can simply use the %s command here in this chat." + .formatted(commandMention)) + .addField("Reason", reason, false) + .setColor(isPunishAction ? Color.RED : Color.GREEN); + + return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME) + .map(embedBuilder); } /** - * Gives out advice depending on the {@link ModerationAction} and the parameters passed into it. - * - * @param action the action that is being performed, such as banning a user. - * @param temporaryData if the action is a temporary action, such as a 1 hour mute. - * @param additionalDescription any extra description that should be part of the message, if - * desired - * @param guild for which the action was triggered. - * @param reason for the action. - * @param textChannel for which messages are being sent to. + * Creates a nice looking embed for the mod action taken with duration * - * @return the appropriate advice. + * @param guild the guild in which the action has been taken + * @param actionTitle the mod action itself + * @param description a short description explaining the action + * @param reason reason for the action taken + * @param duration the duration of mod action + * @return the embed */ - public static RestAction sendDmAdvice(ModerationAction action, - @Nullable TemporaryData temporaryData, @Nullable String additionalDescription, - Guild guild, String reason, PrivateChannel textChannel) { - String additionalDescriptionInfix = - additionalDescription == null ? "" : "\n" + additionalDescription; - - if (REVOKE_ACTIONS.contains(action)) { - return textChannel.sendMessage(""" - Hey there, you have been %s in the server %s.%s - The reason for being %s is: %s - """.formatted(action.getVerb(), guild.getName(), additionalDescriptionInfix, - action.getVerb(), reason)); - } - String durationMessage; - if (SOFT_ACTIONS.contains(action)) { - durationMessage = ""; - } else if (TEMPORARY_ACTIONS.contains(action)) { - durationMessage = - temporaryData == null ? " permanently" : " for " + temporaryData.duration(); - } else { - throw new IllegalArgumentException( - "Action '%s' is not supported by this method".formatted(action)); - } + static RestAction getModActionEmbed(Guild guild, String actionTitle, + String description, String reason, String duration) { + return getModActionEmbed(guild, actionTitle, description, reason, true) + .map(embedBuilder -> embedBuilder.addField("Duration", duration, false)); + } - UnaryOperator createDmMessage = - commandMention -> """ - Hey there, sorry to tell you but unfortunately you have been %s%s in the server %s.%s - To get in touch with a moderator, you can simply use the %s command here in this chat. \ - Your message will then be forwarded and a moderator will get back to you soon 😊 - The reason for being %s is: %s - """ - .formatted(action.getVerb(), durationMessage, guild.getName(), - additionalDescriptionInfix, commandMention, action.getVerb(), reason); + /** + * @param embedBuilder rest action to generate embed from + * @param target the user to send the generated embed + * @return boolean rest action, weather the dm is sent successfully + */ + static RestAction sendModActionDm(RestAction embedBuilder, User target) { + return embedBuilder.map(EmbedBuilder::build) + .flatMap(embed -> target.openPrivateChannel() + .flatMap(channel -> channel.sendMessageEmbeds(embed))) + .mapToResult() + .map(Result::isSuccess); + } - return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME) - .map(createDmMessage) - .flatMap(textChannel::sendMessage); + /** + * Wrapper to hold data relevant to temporary actions, for example the time it expires. + * + * @param expiresAt the time the temporary action expires + * @param duration a human-readable text representing the duration of the temporary action, such + * as {@code "1 day"}. + */ + record TemporaryData(Instant expiresAt, String duration) { } } diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java index 94a4efed9a..7cb70d6c85 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java @@ -1,14 +1,12 @@ package org.togetherjava.tjbot.commands.moderation; import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.events.GenericEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.OptionData; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; -import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +36,7 @@ public final class MuteCommand extends SlashCommandAdapter { private static final String REASON_OPTION = "reason"; private static final String COMMAND_NAME = "mute"; private static final String ACTION_VERB = "mute"; + private static final String ACTION_TITLE = "Mute"; @SuppressWarnings("StaticCollection") private static final List DURATIONS = List.of("10 minutes", "30 minutes", "1 hour", "3 hours", "1 day", "3 days", "7 days", ModerationUtils.PERMANENT_DURATION); @@ -70,16 +69,16 @@ private static void handleAlreadyMutedTarget(IReplyCallback event) { event.reply("The user is already muted.").setEphemeral(true).queue(); } - private static RestAction sendDm(ISnowflake target, - @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild, - GenericEvent event) { - return event.getJDA() - .openPrivateChannelById(target.getId()) - .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.MUTE, temporaryData, - "This means you can no longer send any messages in the server until you have been unmuted again.", - guild, reason, channel)) - .mapToResult() - .map(Result::isSuccess); + private static RestAction sendDm(User target, + @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild) { + String durationMessage = temporaryData == null ? "Permanent" : temporaryData.duration(); + String description = + """ + Hey there, sorry to tell you but unfortunately you have been muted. + This means you can no longer send any messages in the server until you have been unmuted again."""; + + return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild, + ACTION_TITLE, description, reason, durationMessage), target); } private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author, @@ -115,7 +114,7 @@ private AuditableRestAction muteUser(Member target, Member author, private void muteUserFlow(Member target, Member author, @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild, SlashCommandInteractionEvent event) { - sendDm(target, temporaryData, reason, guild, event) + sendDm(target.getUser(), temporaryData, reason, guild) .flatMap(hasSentDm -> muteUser(target, author, temporaryData, reason, guild) .map(result -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, temporaryData, reason)) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java index dffb29292e..f01ac78545 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java @@ -1,13 +1,11 @@ package org.togetherjava.tjbot.commands.moderation; import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.events.GenericEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; -import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +32,7 @@ public final class QuarantineCommand extends SlashCommandAdapter { private static final String REASON_OPTION = "reason"; private static final String COMMAND_NAME = "quarantine"; private static final String ACTION_VERB = "quarantine"; + private static final String ACTION_TITLE = "Quarantine"; private final ModerationActionsStore actionsStore; private final Config config; @@ -61,15 +60,15 @@ private static void handleAlreadyQuarantinedTarget(IReplyCallback event) { event.reply("The user is already quarantined.").setEphemeral(true).queue(); } - private static RestAction sendDm(ISnowflake target, String reason, Guild guild, - GenericEvent event) { - return event.getJDA() - .openPrivateChannelById(target.getIdLong()) - .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.QUARANTINE, null, - "This means you can no longer interact with anyone in the server until you have been unquarantined again.", - guild, reason, channel)) - .mapToResult() - .map(Result::isSuccess); + private static RestAction sendDm(User target, String reason, Guild guild) { + String description = + """ + Hey there, sorry to tell you but unfortunately you have been put under quarantine. + This means you can no longer interact with anyone in the server until you have been unquarantined again."""; + + return ModerationUtils.sendModActionDm( + ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, true), + target); } private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author, @@ -100,7 +99,7 @@ private AuditableRestAction quarantineUser(Member target, Member author, S private void quarantineUserFlow(Member target, Member author, String reason, Guild guild, SlashCommandInteractionEvent event) { - sendDm(target, reason, guild, event) + sendDm(target.getUser(), reason, guild) .flatMap(hasSentDm -> quarantineUser(target, author, reason, guild) .map(result -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason)) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java index ce050fcd07..0f02d11ca8 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java @@ -1,13 +1,11 @@ package org.togetherjava.tjbot.commands.moderation; import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.events.GenericEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; -import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +31,7 @@ public final class UnmuteCommand extends SlashCommandAdapter { private static final String REASON_OPTION = "reason"; private static final String COMMAND_NAME = "unmute"; private static final String ACTION_VERB = "unmute"; + private static final String ACTION_TITLE = "Unmute"; private final ModerationActionsStore actionsStore; private final Config config; @@ -58,15 +57,14 @@ private static void handleNotMutedTarget(IReplyCallback event) { event.reply("The user is not muted.").setEphemeral(true).queue(); } - private static RestAction sendDm(ISnowflake target, String reason, Guild guild, - GenericEvent event) { - return event.getJDA() - .openPrivateChannelById(target.getId()) - .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.UNMUTE, null, - "This means you can now send messages in the server again 👌", guild, reason, - channel)) - .mapToResult() - .map(Result::isSuccess); + private static RestAction sendDm(User target, String reason, Guild guild) { + String description = """ + Hey there, you have been unmuted in the server. + This means you can now send messages in the server again."""; + + return ModerationUtils.sendModActionDm( + ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false), + target); } private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author, @@ -96,7 +94,7 @@ private AuditableRestAction unmuteUser(Member target, Member author, Strin private void unmuteUserFlow(Member target, Member author, String reason, Guild guild, SlashCommandInteractionEvent event) { - sendDm(target, reason, guild, event) + sendDm(target.getUser(), reason, guild) .flatMap( hasSentDm -> unmuteUser(target, author, reason, guild).map(result -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason)) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java index 771d9e787f..37fe8a24c9 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java @@ -1,13 +1,11 @@ package org.togetherjava.tjbot.commands.moderation; import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.events.GenericEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; -import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +32,7 @@ public final class UnquarantineCommand extends SlashCommandAdapter { private static final String REASON_OPTION = "reason"; private static final String COMMAND_NAME = "unquarantine"; private static final String ACTION_VERB = "unquarantine"; + private static final String ACTION_TITLE = "Unquarantine"; private final ModerationActionsStore actionsStore; private final Config config; @@ -62,15 +61,14 @@ private static void handleNotQuarantinedTarget(IReplyCallback event) { event.reply("The user is not quarantined.").setEphemeral(true).queue(); } - private static RestAction sendDm(ISnowflake target, String reason, Guild guild, - GenericEvent event) { - return event.getJDA() - .openPrivateChannelById(target.getIdLong()) - .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.UNQUARANTINE, null, - "This means you can now interact with others in the server again 👌", guild, - reason, channel)) - .mapToResult() - .map(Result::isSuccess); + private static RestAction sendDm(User target, String reason, Guild guild) { + String description = """ + Hey there, you have been put out of quarantine in the server. + This means you can now interact with others in the server again."""; + + return ModerationUtils.sendModActionDm( + ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false), + target); } private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author, @@ -101,7 +99,7 @@ private AuditableRestAction unquarantineUser(Member target, Member author, private void unquarantineUserFlow(Member target, Member author, String reason, Guild guild, SlashCommandInteractionEvent event) { - sendDm(target, reason, guild, event) + sendDm(target.getUser(), reason, guild) .flatMap(hasSentDm -> unquarantineUser(target, author, reason, guild) .map(result -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason)) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java index 26b767b652..d476855b7a 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java @@ -6,7 +6,6 @@ import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.requests.RestAction; -import net.dv8tion.jda.api.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,6 +29,7 @@ public final class WarnCommand extends SlashCommandAdapter { private static final String USER_OPTION = "user"; private static final String REASON_OPTION = "reason"; private static final String ACTION_VERB = "warn"; + private static final String ACTION_TITLE = "Warning"; private final ModerationActionsStore actionsStore; /** @@ -48,7 +48,7 @@ public WarnCommand(ModerationActionsStore actionsStore) { private RestAction warnUserFlow(User target, Member author, String reason, Guild guild, SlashCommandInteractionEvent event) { - return dmUser(target, reason, guild, event).map(hasSentDm -> { + return sendDm(target, reason, guild).map(hasSentDm -> { warnUser(target, author, reason, guild); return hasSentDm; }) @@ -56,14 +56,13 @@ private RestAction warnUserFlow(User target, Member author, Str .flatMap(event::replyEmbeds); } - private static RestAction dmUser(ISnowflake target, String reason, Guild guild, - SlashCommandInteractionEvent event) { - return event.getJDA() - .openPrivateChannelById(target.getId()) - .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.WARN, null, null, - guild, reason, channel)) - .mapToResult() - .map(Result::isSuccess); + private static RestAction sendDm(User target, String reason, Guild guild) { + String description = + "Hey there, sorry to tell you but unfortunately you have been warned in the server."; + + return ModerationUtils.sendModActionDm( + ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, true), + target); } private void warnUser(User target, Member author, String reason, Guild guild) { From b83e446786946ebc8c446f6f09ae6295ab299683 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Fri, 21 Oct 2022 17:12:23 +0530 Subject: [PATCH 2/8] removed unused fields --- .../commands/moderation/ModerationUtils.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java index 3c550577ae..0c9b8ff592 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java @@ -52,23 +52,6 @@ private ModerationUtils() { */ static final Color AMBIENT_COLOR = Color.decode("#895FE8"); - /** - * Actions with timely constraint, like being muted for 1 hour. - */ - private static final Set TEMPORARY_ACTIONS = - EnumSet.of(ModerationAction.MUTE); - /** - * Actions with revoking previously made actions on the user, like unmuting the user after it - * has been muted. - */ - private static final Set REVOKE_ACTIONS = - EnumSet.of(ModerationAction.UNMUTE, ModerationAction.UNQUARANTINE); - /** - * Soft violations were the user still remains member of the guild, such as a warning - */ - private static final Set SOFT_ACTIONS = - EnumSet.of(ModerationAction.WARN, ModerationAction.QUARANTINE); - /** * Checks whether the given reason is valid. If not, it will handle the situation and respond to * the user. From 7706aed6b032612fa75b77a0b4a584e8b7993553 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Sat, 22 Oct 2022 12:20:23 +0530 Subject: [PATCH 3/8] improvements --- .../commands/moderation/ModerationUtils.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java index 0c9b8ff592..653c6b71de 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java @@ -7,6 +7,7 @@ import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; import net.dv8tion.jda.api.utils.Result; +import net.dv8tion.jda.internal.requests.CompletedRestAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,10 +21,7 @@ import java.time.Instant; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalUnit; -import java.util.EnumSet; import java.util.Optional; -import java.util.Set; -import java.util.function.Function; import java.util.function.Predicate; import java.util.regex.Pattern; @@ -382,17 +380,21 @@ static Optional computeTemporaryData(String durationText) { */ static RestAction getModActionEmbed(Guild guild, String actionTitle, String description, String reason, boolean isPunishAction) { - Function embedBuilder = commandMention -> new EmbedBuilder() - .setAuthor(guild.getName(), null, guild.getIconUrl()) - .setTitle(actionTitle) - .setDescription(description - + "\n\nTo get in touch with a moderator, you can simply use the %s command here in this chat." - .formatted(commandMention)) - .addField("Reason", reason, false) - .setColor(isPunishAction ? Color.RED : Color.GREEN); + EmbedBuilder modActionEmbed = + new EmbedBuilder().setAuthor(guild.getName(), null, guild.getIconUrl()) + .setTitle(actionTitle) + .setDescription(description) + .addField("Reason", reason, false) + .setColor(ModerationUtils.AMBIENT_COLOR); + + if (!isPunishAction) { + return new CompletedRestAction<>(guild.getJDA(), modActionEmbed); + } return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME) - .map(embedBuilder); + .map(commandMention -> modActionEmbed.appendDescription( + "\n\nTo get in touch with a moderator, you can use the %s command here." + .formatted(commandMention))); } /** From 33d36f7666c90c050953a6fc215b84cbd1138c24 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Sat, 22 Oct 2022 12:35:13 +0530 Subject: [PATCH 4/8] improved docs --- .../togetherjava/tjbot/commands/moderation/ModerationUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java index 653c6b71de..14e411ddfd 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java @@ -372,7 +372,7 @@ static Optional computeTemporaryData(String durationText) { * Creates a nice looking embed for the mod action taken. * * @param guild the guild in which the action has been taken - * @param actionTitle the mod action itself e.g, Ban + * @param actionTitle the mod action as title e.g, Ban * @param description a short description explaining the action * @param reason reason for the action taken * @param isPunishAction is it a punish action e.g. ban, warn From 38a744a604d49715738c407f0a0b155681db3c7c Mon Sep 17 00:00:00 2001 From: Taz03 Date: Sat, 22 Oct 2022 12:41:03 +0530 Subject: [PATCH 5/8] code fixes --- .../togetherjava/tjbot/commands/moderation/ModerationUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java index 14e411ddfd..2da790d545 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java @@ -393,7 +393,7 @@ static RestAction getModActionEmbed(Guild guild, String actionTitl return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME) .map(commandMention -> modActionEmbed.appendDescription( - "\n\nTo get in touch with a moderator, you can use the %s command here." + "%n%nTo get in touch with a moderator, you can use the %s command here." .formatted(commandMention))); } From 21bea5c7b322ea3f84aebb15df734e4cf09a9de9 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Mon, 23 Jan 2023 18:41:37 +0530 Subject: [PATCH 6/8] code fixes --- .../org/togetherjava/tjbot/commands/moderation/MuteCommand.java | 2 +- .../tjbot/commands/moderation/QuarantineCommand.java | 2 +- .../org/togetherjava/tjbot/commands/moderation/WarnCommand.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java index 2f19bce2c7..329f8c5af3 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java @@ -116,7 +116,7 @@ private void muteUserFlow(Member target, Member author, SlashCommandInteractionEvent event) { event.deferReply().queue(); - sendDm(target.getUser(), temporaryData, reason, guild, event) + sendDm(target.getUser(), temporaryData, reason, guild) .flatMap(hasSentDm -> muteUser(target, author, temporaryData, reason, guild) .map(result -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, temporaryData, reason)) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java index 0a4a629741..f097ed01b1 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java @@ -101,7 +101,7 @@ private void quarantineUserFlow(Member target, Member author, String reason, Gui SlashCommandInteractionEvent event) { event.deferReply().queue(); - sendDm(target.getUser(), reason, guild, event) + sendDm(target.getUser(), reason, guild) .flatMap(hasSentDm -> quarantineUser(target, author, reason, guild) .map(result -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason)) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java index efa5ec05d1..baaa6de749 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java @@ -49,7 +49,7 @@ private void warnUserFlow(User target, Member author, String reason, Guild guild SlashCommandInteractionEvent event) { event.deferReply().queue(); - dmUser(target, reason, guild, event).map(hasSentDm -> { + sendDm(target, reason, guild).map(hasSentDm -> { warnUser(target, author, reason, guild); return hasSentDm; }) From 6172c994406a938caba6387c01a06b6c6040be0b Mon Sep 17 00:00:00 2001 From: Taz03 Date: Sat, 28 Jan 2023 02:24:36 +0530 Subject: [PATCH 7/8] fixes --- .../tjbot/commands/moderation/BanCommand.java | 8 +++++--- .../tjbot/commands/moderation/KickCommand.java | 7 +++++-- .../tjbot/commands/moderation/ModerationUtils.java | 13 +++++++------ .../tjbot/commands/moderation/MuteCommand.java | 5 +++-- .../tjbot/commands/moderation/UnmuteCommand.java | 2 +- .../commands/moderation/UnquarantineCommand.java | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java index 9dc2e63686..c7ca7b983e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java @@ -84,11 +84,13 @@ private static RestAction handleAlreadyBanned(Guild.Ban ban, Interactio private static RestAction sendDm(User target, @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild) { String durationMessage = temporaryData == null ? "Permanently" : temporaryData.duration(); - String description = - "Hey there, sorry to tell you but unfortunately you have been banned from the server."; + String description = """ + Hey there, sorry to tell you but unfortunately you have been banned from the server. + If you this this was a mistake, please contact a moderator or admin of this server + """; return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild, - ACTION_TITLE, description, reason, durationMessage), target); + ACTION_TITLE, description, reason, durationMessage, false), target); } private static MessageEmbed sendFeedback(boolean hasSentDm, User target, Member author, diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java index 3ce2b4dade..012006cb92 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java @@ -67,10 +67,13 @@ private void kickUserFlow(Member target, Member author, String reason, Guild gui } private static RestAction sendDm(User target, String reason, Guild guild) { - String description = "Hey there, sorry to tell you but unfortunately you have been kicked"; + String description = """ + Hey there, sorry to tell you but unfortunately you have been kicked from the server. + If you this this was a mistake, please contact a moderator or admin of this server + """; return ModerationUtils.sendModActionDm( - ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, true), + ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false), target); } diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java index 2da790d545..00c7b93743 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java @@ -375,11 +375,11 @@ static Optional computeTemporaryData(String durationText) { * @param actionTitle the mod action as title e.g, Ban * @param description a short description explaining the action * @param reason reason for the action taken - * @param isPunishAction is it a punish action e.g. ban, warn + * @param showModmail to show mod contact details or not * @return the embed */ static RestAction getModActionEmbed(Guild guild, String actionTitle, - String description, String reason, boolean isPunishAction) { + String description, String reason, boolean showModmail) { EmbedBuilder modActionEmbed = new EmbedBuilder().setAuthor(guild.getName(), null, guild.getIconUrl()) .setTitle(actionTitle) @@ -387,13 +387,13 @@ static RestAction getModActionEmbed(Guild guild, String actionTitl .addField("Reason", reason, false) .setColor(ModerationUtils.AMBIENT_COLOR); - if (!isPunishAction) { + if (!showModmail) { return new CompletedRestAction<>(guild.getJDA(), modActionEmbed); } return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME) .map(commandMention -> modActionEmbed.appendDescription( - "%n%nTo get in touch with a moderator, you can use the %s command here." + "%n%nTo get in touch with a moderator, you can use the %s command here in this chat. Your message will then forwarded and a moderator will get back to you soon 😊" .formatted(commandMention))); } @@ -405,11 +405,12 @@ static RestAction getModActionEmbed(Guild guild, String actionTitl * @param description a short description explaining the action * @param reason reason for the action taken * @param duration the duration of mod action + * @param showModmail to show mod contact details or not * @return the embed */ static RestAction getModActionEmbed(Guild guild, String actionTitle, - String description, String reason, String duration) { - return getModActionEmbed(guild, actionTitle, description, reason, true) + String description, String reason, String duration, boolean showModmail) { + return getModActionEmbed(guild, actionTitle, description, reason, showModmail) .map(embedBuilder -> embedBuilder.addField("Duration", duration, false)); } diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java index 329f8c5af3..fb89c8a48e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java @@ -75,10 +75,11 @@ private static RestAction sendDm(User target, String description = """ Hey there, sorry to tell you but unfortunately you have been muted. - This means you can no longer send any messages in the server until you have been unmuted again."""; + This means you can no longer send any messages in the server until you have been unmuted again. + """; return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild, - ACTION_TITLE, description, reason, durationMessage), target); + ACTION_TITLE, description, reason, durationMessage, true), target); } private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author, diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java index 0f02d11ca8..ce48cc10fd 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java @@ -60,7 +60,7 @@ private static void handleNotMutedTarget(IReplyCallback event) { private static RestAction sendDm(User target, String reason, Guild guild) { String description = """ Hey there, you have been unmuted in the server. - This means you can now send messages in the server again."""; + This means you can now send messages in the server again 👌"""; return ModerationUtils.sendModActionDm( ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false), diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java index 37fe8a24c9..01273f2098 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java @@ -64,7 +64,7 @@ private static void handleNotQuarantinedTarget(IReplyCallback event) { private static RestAction sendDm(User target, String reason, Guild guild) { String description = """ Hey there, you have been put out of quarantine in the server. - This means you can now interact with others in the server again."""; + This means you can now interact with others in the server again 👌"""; return ModerationUtils.sendModActionDm( ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false), From fd955701dcb07b884ff1c019dc253e274524d48b Mon Sep 17 00:00:00 2001 From: Taz03 Date: Mon, 30 Jan 2023 17:59:42 +0530 Subject: [PATCH 8/8] CR --- .../tjbot/commands/moderation/BanCommand.java | 8 ++++---- .../tjbot/commands/moderation/KickCommand.java | 8 ++++---- .../tjbot/commands/moderation/ModerationUtils.java | 14 +++++++------- .../tjbot/commands/moderation/MuteCommand.java | 3 +-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java index c7ca7b983e..5172342e2e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java @@ -84,10 +84,10 @@ private static RestAction handleAlreadyBanned(Guild.Ban ban, Interactio private static RestAction sendDm(User target, @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild) { String durationMessage = temporaryData == null ? "Permanently" : temporaryData.duration(); - String description = """ - Hey there, sorry to tell you but unfortunately you have been banned from the server. - If you this this was a mistake, please contact a moderator or admin of this server - """; + String description = + """ + Hey there, sorry to tell you but unfortunately you have been banned from the server. + If you think this was a mistake, please contact a moderator or admin of this server."""; return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, durationMessage, false), target); diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java index 012006cb92..fde20e5413 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java @@ -67,10 +67,10 @@ private void kickUserFlow(Member target, Member author, String reason, Guild gui } private static RestAction sendDm(User target, String reason, Guild guild) { - String description = """ - Hey there, sorry to tell you but unfortunately you have been kicked from the server. - If you this this was a mistake, please contact a moderator or admin of this server - """; + String description = + """ + Hey there, sorry to tell you but unfortunately you have been kicked from the server. + If you think this was a mistake, please contact a moderator or admin of this server."""; return ModerationUtils.sendModActionDm( ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false), diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java index 00c7b93743..d72d6f162d 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java @@ -375,11 +375,11 @@ static Optional computeTemporaryData(String durationText) { * @param actionTitle the mod action as title e.g, Ban * @param description a short description explaining the action * @param reason reason for the action taken - * @param showModmail to show mod contact details or not + * @param showModmailAdvice whether to advice on how to use the modmail command * @return the embed */ static RestAction getModActionEmbed(Guild guild, String actionTitle, - String description, String reason, boolean showModmail) { + String description, String reason, boolean showModmailAdvice) { EmbedBuilder modActionEmbed = new EmbedBuilder().setAuthor(guild.getName(), null, guild.getIconUrl()) .setTitle(actionTitle) @@ -387,13 +387,13 @@ static RestAction getModActionEmbed(Guild guild, String actionTitl .addField("Reason", reason, false) .setColor(ModerationUtils.AMBIENT_COLOR); - if (!showModmail) { + if (!showModmailAdvice) { return new CompletedRestAction<>(guild.getJDA(), modActionEmbed); } return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME) .map(commandMention -> modActionEmbed.appendDescription( - "%n%nTo get in touch with a moderator, you can use the %s command here in this chat. Your message will then forwarded and a moderator will get back to you soon 😊" + "%n%nTo get in touch with a moderator, you can use the %s command here in this chat. Your message will then be forwarded and a moderator will get back to you soon 😊" .formatted(commandMention))); } @@ -405,12 +405,12 @@ static RestAction getModActionEmbed(Guild guild, String actionTitl * @param description a short description explaining the action * @param reason reason for the action taken * @param duration the duration of mod action - * @param showModmail to show mod contact details or not + * @param showModmailAdvice whether to advice on how to use the modmail command * @return the embed */ static RestAction getModActionEmbed(Guild guild, String actionTitle, - String description, String reason, String duration, boolean showModmail) { - return getModActionEmbed(guild, actionTitle, description, reason, showModmail) + String description, String reason, String duration, boolean showModmailAdvice) { + return getModActionEmbed(guild, actionTitle, description, reason, showModmailAdvice) .map(embedBuilder -> embedBuilder.addField("Duration", duration, false)); } diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java index fb89c8a48e..6c936e7554 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java @@ -75,8 +75,7 @@ private static RestAction sendDm(User target, String description = """ Hey there, sorry to tell you but unfortunately you have been muted. - This means you can no longer send any messages in the server until you have been unmuted again. - """; + This means you can no longer send any messages in the server until you have been unmuted again."""; return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, durationMessage, true), target);