diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ReportCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ReportCommand.java index 005e779587..6127e84f58 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ReportCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ReportCommand.java @@ -6,6 +6,7 @@ import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent; @@ -52,6 +53,7 @@ public final class ReportCommand extends BotCommandAdapter implements MessageCon private static final Color AMBIENT_COLOR = Color.BLACK; private final Cache authorToLastReportInvocation = createCooldownCache(); private final Predicate modMailChannelNamePredicate; + private final Predicate configModGroupPattern; private final String configModMailChannelPattern; /** @@ -66,6 +68,9 @@ public ReportCommand(Config config) { Pattern.compile(config.getModMailChannelPattern()).asMatchPredicate(); configModMailChannelPattern = config.getModMailChannelPattern(); + + configModGroupPattern = + Pattern.compile(config.getHeavyModerationRolePattern()).asMatchPredicate(); } private Cache createCooldownCache() { @@ -177,9 +182,21 @@ private MessageCreateAction createModMessage(String reportReason, .setDescription(reportReason) .setColor(AMBIENT_COLOR) .build(); - return modMailAuditLog.sendMessageEmbeds(reportedMessageEmbed, reportReasonEmbed) - .addActionRow(DiscordClientAction.Channels.GUILD_CHANNEL_MESSAGE.asLinkButton( - "Go to Message", guild.getId(), reportedMessage.channelID, reportedMessage.id)); + + MessageCreateAction message = + modMailAuditLog.sendMessageEmbeds(reportedMessageEmbed, reportReasonEmbed) + .addActionRow(DiscordClientAction.Channels.GUILD_CHANNEL_MESSAGE.asLinkButton( + "Go to Message", guild.getId(), reportedMessage.channelID, + reportedMessage.id)); + + Optional moderatorRole = guild.getRoles() + .stream() + .filter(role -> configModGroupPattern.test(role.getName())) + .findFirst(); + + moderatorRole.ifPresent(role -> message.setContent(role.getAsMention())); + + return message; } private void sendModMessage(ModalInteractionEvent event, List args, diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java index 8a83c3badb..0ab3181f7a 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java @@ -5,6 +5,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; @@ -50,6 +51,7 @@ public final class ModMailCommand extends SlashCommandAdapter { private static final Color AMBIENT_COLOR = Color.BLACK; private final Cache authorToLastModMailInvocation = createCooldownCache(); private final Predicate modMailChannelNamePredicate; + private final Predicate configModGroupPattern; private final String configModMailChannelPattern; @@ -83,6 +85,9 @@ public ModMailCommand(JDA jda, Config config) { Pattern.compile(config.getModMailChannelPattern()).asMatchPredicate(); configModMailChannelPattern = config.getModMailChannelPattern(); + + configModGroupPattern = + Pattern.compile(config.getHeavyModerationRolePattern()).asMatchPredicate(); } private Cache createCooldownCache() { @@ -148,6 +153,15 @@ private MessageCreateAction createModMessage(SlashCommandInteractionEvent event, message.addActionRow(DiscordClientAction.General.USER.asLinkButton("Author Profile", String.valueOf(userId))); } + + Optional moderatorRole = event.getGuild() + .getRoles() + .stream() + .filter(role -> configModGroupPattern.test(role.getName())) + .findFirst(); + + moderatorRole.ifPresent(role -> message.setContent(role.getAsMention())); + return message; }