Skip to content

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

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

firasrg wants to merge 5 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

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

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.

i dont quite follow. can u provide details and maybe screenshots pls, thanks

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.

Background: handleWasAlreadyReportedMessage() stores the message ID in reportedMessageToTimestamp before the alert is posted to the mod channel, to block duplicate reports. That entry lives for 1 day. (The per-user cooldown is a separate 1 minute timer.)

The problem: if posting the alert then fails, the entry stays. Nobody can report that message again for 24h, even though the mods never saw it.

How to reproduce (I renamed the modmail channel so the pattern doesn’t match, but denying the bot “Send Messages” there fails the same way):

  1. Rename the modmail channel so the lookup fails, then report a message.
    👉 User gets “Sorry, there was an issue forwarding your report…” and the log says “Cannot find the designated mod mail channel…”

  2. Rename the channel back and report the same message again (after the 1 minute cooldown).

Without the invalidate calls: the second report is rejected with “This message was already reported.” although no alert was ever posted.

With the invalidate calls: the failure paths remove the entry, so the second report goes through and the mods get the alert.

Successful reports are unaffected, since invalidate only runs in the 2 failure branches (mod channel not found, and sending the alert failed).

It’s a small robustness fix, but if you’d prefer to keep it out of this PR I’m happy to split it into a separate one!

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.

proof (1)

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

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.

its still there

@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