Skip to content

Feat/cross channel spam automod#553

Open
Neil-Tomar wants to merge 2 commits into
Java-Discord:mainfrom
Neil-Tomar:feat/cross-channel-spam-automod
Open

Feat/cross channel spam automod#553
Neil-Tomar wants to merge 2 commits into
Java-Discord:mainfrom
Neil-Tomar:feat/cross-channel-spam-automod

Conversation

@Neil-Tomar

Copy link
Copy Markdown
Contributor

Summary

Adds a second spam automod — checkCrossChannelSpam in AutoMod — that catches a pattern the existing same-channel spam check misses: a single user rapidly spreading messages across several different channels.

What it does

  • Flags a user who posts in more than a configured number of distinct channels within a configured time window.
  • On a match, applies the existing 6-hour spam timeout and deletes the matched messages.
  • Both thresholds live in ModerationConfig, so they're tunable per guild.

How it works

  • CachedMessage now stores a channelId, taken from the live message when it's cached — so the cache knows which channel each message came from. That's what lets the check count distinct channels without any extra Discord API calls; only the timeout and the deletions talk to Discord.
  • checkCrossChannelSpam reads the author's recent messages from the MessageCache within the window, gathers the distinct channels, and passes the messages to handleSpam once the count crosses the threshold.
  • handleSpam gains a List<CachedMessage> overload that times the user out and deletes each message by id.
  • New ModerationConfig fields: crossChannelSpamWindowSeconds and crossChannelSpamMinChannels.

Notes

  • channelId isn't persisted to the database yet — it defaults to -1 when read from the DB, per your suggestion. If it holds up, I can follow with a migration to store it properly.
  • The trigger currently uses the distinct-channel count only. Your spec also mentioned a message count, so I'm happy to add a separate minimum-messages threshold if you'd like both.

@Neil-Tomar
Neil-Tomar requested a review from a team as a code owner July 17, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant