Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,6 +53,7 @@ public final class ReportCommand extends BotCommandAdapter implements MessageCon
private static final Color AMBIENT_COLOR = Color.BLACK;
private final Cache<Long, Instant> authorToLastReportInvocation = createCooldownCache();
private final Predicate<String> modMailChannelNamePredicate;
private final Predicate<String> configModGroupPattern;
private final String configModMailChannelPattern;

/**
Expand All @@ -66,6 +68,9 @@ public ReportCommand(Config config) {
Pattern.compile(config.getModMailChannelPattern()).asMatchPredicate();

configModMailChannelPattern = config.getModMailChannelPattern();

configModGroupPattern =
Pattern.compile(config.getHeavyModerationRolePattern()).asMatchPredicate();
}

private Cache<Long, Instant> createCooldownCache() {
Expand Down Expand Up @@ -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<Role> 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<String> args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +51,7 @@ public final class ModMailCommand extends SlashCommandAdapter {
private static final Color AMBIENT_COLOR = Color.BLACK;
private final Cache<Long, Instant> authorToLastModMailInvocation = createCooldownCache();
private final Predicate<String> modMailChannelNamePredicate;
private final Predicate<String> configModGroupPattern;
private final String configModMailChannelPattern;


Expand Down Expand Up @@ -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<Long, Instant> createCooldownCache() {
Expand Down Expand Up @@ -148,6 +153,15 @@ private MessageCreateAction createModMessage(SlashCommandInteractionEvent event,
message.addActionRow(DiscordClientAction.General.USER.asLinkButton("Author Profile",
String.valueOf(userId)));
}

Optional<Role> moderatorRole = event.getGuild()
.getRoles()
.stream()
.filter(role -> configModGroupPattern.test(role.getName()))
.findFirst();

moderatorRole.ifPresent(role -> message.setContent(role.getAsMention()));

return message;
}

Expand Down