Repository navigation
Conversation
d3aa2f7 to
1edf9cc
Compare
| * </ul> | ||
| * The ban and unban only serves to delete the messages, the user is free to join back afterward. | ||
| */ | ||
| public final class ThisIsScamCommand extends BotCommandAdapter implements MessageContextCommand { |
There was a problem hiding this comment.
(rename the file, ThisIsAgainstRulesCommand)
There was a problem hiding this comment.
Will do it at the end
|
|
||
| private final Cache<Long, Instant> reportedMessageToTimestamp = | ||
| Caffeine.newBuilder().maximumSize(10_000).expireAfterWrite(Duration.ofDays(1)).build(); | ||
|
|
| * @param config to resolve the mod mail channel and quarantined role | ||
| * @param actionsStore used to store issued quarantine and warn actions |
There was a problem hiding this comment.
this will continue to rot, just like it already did. lets rephrase. resolve the mod channel. used to store issued moderative actions.
| Optional<TextChannel> modMailChannel = findModMailChannel(event); | ||
| if (modMailChannel.isEmpty()) { |
There was a problem hiding this comment.
same here. lets roll with findModChannel and modChannel instead to prevent it being outdated again if we change the channel name in the future
| Message message = event.getTarget(); | ||
| Optional<TextChannel> modMailChannel = findModMailChannel(event); | ||
| if (modMailChannel.isEmpty()) { | ||
| reportedMessageToTimestamp.invalidate(message.getIdLong()); |
There was a problem hiding this comment.
It's an edge-case: I noticed an issue while doing the tests. I know the handleWasAlreadyReportedMessage() puts the message Id in reportedMessageToTimestamp before the alert is sent to mods, to block duplicate reports. But If the send then fails, the message stay marked as already reported for the cooldown duration. which is 1 day and I keep getting that msg again an again. But with this change, invalidating that entry on failure so the report can be retried once a problem is fixed. It only runs on the failure cases -> the successful alerts are unaffected
| private static RestAction<Void> deleteMessagesByBanAndUnban(Guild guild, User target, | ||
| String reason) { | ||
| return guild.ban(target, 1, TimeUnit.DAYS) | ||
| .reason(reason) | ||
| .flatMap(_ -> guild.unban(target).reason(reason)); | ||
| } | ||
|
|
||
| private static RestAction<Boolean> sendDm(Guild guild, User target, String title, | ||
| String description, String reason) { | ||
| return ModerationUtils.sendModActionDm( | ||
| ModerationUtils.getModActionEmbed(guild, title, description, reason, true), target); | ||
| } | ||
|
|
||
| private void recordAction(Guild guild, Member target, Member moderator, ModerationAction action, | ||
| String reason) { | ||
| logger.info(LogMarkers.SENSITIVE, | ||
| "'{}' ({}) quarantined the user '{}' ({}) in guild '{}' for reason '{}'.", | ||
| moderator.getUser().getName(), moderator.getId(), target.getUser().getName(), | ||
| target.getId(), guild.getName(), ACTION_REASON); | ||
| "'{}' ({}) executed '{}' against the user '{}' ({}) in guild '{}' for reason '{}'.", | ||
| moderator.getUser().getName(), moderator.getId(), action, | ||
| target.getUser().getName(), target.getId(), guild.getName(), reason); | ||
|
|
||
| actionsStore.addAction(guild.getIdLong(), moderator.getIdLong(), target.getIdLong(), action, | ||
| null, reason); | ||
| } |
There was a problem hiding this comment.
the order for this is incorrect. should be:
- sendDm
- recordAction
- deleteMessagesByBanAndUnban
| } | ||
|
|
||
| private RestAction<Void> quarantineUser(Guild guild, Member target, Member moderator) { | ||
| private static RestAction<Void> deleteMessagesByBanAndUnban(Guild guild, User target, |
There was a problem hiding this comment.
not "BanAndUnban" but "BanThenUnban". or just "BanUnban", also fine by me (i know it was like that before, but please improve)
| private static List<MessageEmbed> withResult(List<MessageEmbed> alertEmbeds, String text, | ||
| Color color) { | ||
| MessageEmbed resultEmbed = new EmbedBuilder().setDescription(text).setColor(color).build(); | ||
|
|
||
| List<MessageEmbed> embeds = new ArrayList<>(alertEmbeds); | ||
| embeds.add(resultEmbed); | ||
|
|
||
| actionsStore.addAction(guild.getIdLong(), moderator.getIdLong(), target.getIdLong(), | ||
| ModerationAction.QUARANTINE, null, ACTION_REASON); | ||
| return embeds; | ||
| } |
There was a problem hiding this comment.
wrong order. this needs to go up to where its used, else its confusing
| private static void showResult(InteractionHook hook, List<MessageEmbed> alertEmbeds, | ||
| String text, Color color) { | ||
| hook.editOriginalEmbeds(withResult(alertEmbeds, text, color)).queue(); |
There was a problem hiding this comment.
mh, i dont think this helps readability. remove this method please
| private enum AlertAction { | ||
| SCAM, | ||
| JOB_AD, | ||
| DISMISS |
ThisIsAgainstRulesCommand (Scam and Job-Ad) (formerly ThisIsScam, only Scam)
|



What
Replaces the
this-is-scammessage context command with a more genericthis-is-against-rulescommand (ThisIsAgainstRulesCommand).When a user reports a message, mods now get three buttons instead of Yes/No:
WARN), then ban + unban to delete the recent messages.In both Scam and Job-Ad the ban/unban only serves to delete the message history,
the user can join back right away.