Skip to content

Added ThisIsAgainstRulesCommand (Scam and Job-Ad) (formerly ThisIsScam, only Scam) - #1567

Open
firasrg wants to merge 4 commits into
developfrom
firasrg/feature/new-command-rule-violation-alert
Open

firasrg wants to merge 4 commits into
developfrom
firasrg/feature/new-command-rule-violation-alert

Conversation

@firasrg

@firasrg firasrg commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Replaces the this-is-scam message context command with a more generic
this-is-against-rules command (ThisIsAgainstRulesCommand).

When a user reports a message, mods now get three buttons instead of Yes/No:

Button What happens
Scam Same flow as before: DM, quarantine, then ban + unban to delete the recent messages.
Job-Ad DM, warning recorded (WARN), then ban + unban to delete the recent messages.
Dismiss Nothing happens, the alert is closed.

In both Scam and Job-Ad the ban/unban only serves to delete the message history,
the user can join back right away.

image

@firasrg
firasrg requested a review from a team as a code owner October 9, 2026 23:41
@firasrg
firasrg force-pushed the firasrg/feature/new-command-rule-violation-alert branch from d3aa2f7 to 1edf9cc Compare October 9, 2026 23:53
* </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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(rename the file, ThisIsAgainstRulesCommand)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do it at the end


private final Cache<Long, Instant> reportedMessageToTimestamp =
Caffeine.newBuilder().maximumSize(10_000).expireAfterWrite(Duration.ofDays(1)).build();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo that newline pls, thanks

Comment on lines +92 to +93
* @param config to resolve the mod mail channel and quarantined role
* @param actionsStore used to store issued quarantine and warn actions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will continue to rot, just like it already did. lets rephrase. resolve the mod channel. used to store issued moderative actions.

Comment on lines +113 to +114
Optional<TextChannel> modMailChannel = findModMailChannel(event);
if (modMailChannel.isEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why that logic change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +335 to +357
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);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the order for this is incorrect. should be:

  1. sendDm
  2. recordAction
  3. deleteMessagesByBanAndUnban

}

private RestAction<Void> quarantineUser(Guild guild, Member target, Member moderator) {
private static RestAction<Void> deleteMessagesByBanAndUnban(Guild guild, User target,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not "BanAndUnban" but "BanThenUnban". or just "BanUnban", also fine by me (i know it was like that before, but please improve)

Comment on lines +359 to +367
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;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong order. this needs to go up to where its used, else its confusing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method deleted

Comment on lines +369 to +371
private static void showResult(InteractionHook hook, List<MessageEmbed> alertEmbeds,
String text, Color color) {
hook.editOriginalEmbeds(withResult(alertEmbeds, text, color)).queue();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mh, i dont think this helps readability. remove this method please

Comment on lines +374 to +377
private enum AlertAction {
SCAM,
JOB_AD,
DISMISS

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename ReportAction

@Zabuzard Zabuzard changed the title Feat: Turn “this is scam” command into a generic option (Scam | Job-Ad | Dismiss) Added ThisIsAgainstRulesCommand (Scam and Job-Ad) (formerly ThisIsScam, only Scam) Oct 10, 2026
@Zabuzard Zabuzard added enhance command Modify or improve an existing command or group of commands of the bot priority: normal priority: major and removed priority: normal labels Oct 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhance command Modify or improve an existing command or group of commands of the bot priority: major

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants