Attachment Spam

Flag messages that attach too many files at once. A simple per-message count check to stop drive-by file dumps.

Open AutoMod
Per-Message Attachment Limit

Attachment Spam fires when a single message contains more attached files than the threshold you set. It is the thinnest trigger in AutoMod — one configuration field, one count check.

What is this?

A rule that fires when a single message attaches more files than your threshold (default 5). One configuration field, one count check, no pattern matching.

Why you might want it

For the ten-image dumps in one message that crash slower clients, and the upload-bait users who attach six screenshots when one would do. It's also a soft defence against payload spam from compromised accounts. The default of five is comfortably above any normal share.

Setup time: under a minuteDifficulty: Easy. Most users get through it first try.
How this rule works
Checks:The message's attachment list (message.attachments).
Triggers when:The attached file count is strictly greater than max_attachments.
Ignores:Exempt roles and exempt channels. Allowlist words do not apply — Attachment Spam is a volumetric trigger.
Counts toward spam buffers:No — this trigger is per-message, not volumetric.

Why use this rule?

  • Stops low-effort image floods and "gallery dump" raids in chat channels.
  • Prevents abuse where a single user pastes 10+ files to derail a conversation.
  • Cheap insurance against payload-based bots that drop several files in one shot.
  • Pairs cleanly with exempt channels so dedicated showcase / meme spaces stay untouched.

What it detects

A single message with more attached files than your configured maximum. The evaluator runs len(message.attachments) > max_attachments — nothing more.

What it does NOT detect

  • Attachments accumulated across multiple messages — it is strictly per-message.
  • Attachment type, size, or content — images, videos, and executables are counted the same.
  • Embeds. A message with five YouTube or Twitter previews contains zero attachments.
  • Stickers. Those live on message.stickers, not message.attachments.

Configuration

FieldTypeDefaultWhat it means
max_attachmentsinteger5The rule fires when a message has more than this many attached files.

Recommended starter settings

For a general-purpose chat server:

{
  "max_attachments": 5
}
ℹ️
Note
Discord's own client caps attachments at 10 per message (25 with Nitro). Setting max_attachments above 10 means this rule rarely fires for non-Nitro users.

Common false positives

  • Meme dumps or screenshot galleries in #general when the admin forgot to exempt a dedicated channel.
  • Bug-report threads where a reporter attaches multiple screenshots in one message.
  • Legitimate asset bundles — fonts, art commissions, mod packs.
  • Art channels where artists post a WIP set in a single message.

How to test this rule safely

1

Set the rule to Log Only

Log Only records matches without taking action. It is the right starting point for every AutoMod rule.

2

Lower the threshold for testing

Temporarily set max_attachments to 2 so you can trigger the rule with a handful of small images.

3

Post a message with 3 attachments

In a test channel you control, send a message with three tiny image attachments. Check the Event Log dashboard — you should see an entry with matched_pattern = "3 attachments".

4

Confirm a 2-attachment message does NOT fire

Post a message with exactly 2 attachments. No Event Log entry should appear — the comparison is strictly greater than.

5

Flip to Live

Restore your real threshold and switch the rule from Log Only to Live.

Known current behavior

  • Current behavior: embeds and stickers do not count as attachments. A message with five Twitter previews or a pile of stickers will not trigger this rule.
  • Current behavior: allowlist words do not apply. Attachment Spam is a volumetric trigger, so the rule's allowlist_words are ignored for attachment counting — a captioned flood can no longer sneak past the rule just because it contains an allowlisted word.
  • Current behavior: the threshold uses a strict greater-than comparison. Setting max_attachments = 5 means six attachments fires; five does not.
  • Current behavior: an attachment-only message still triggers the rule. Empty message content does not exempt a file dump from the count check.

Action reference

Pair this trigger with any of the five AutoMod actions. Trigger-specific note: Discord deletes attachments alongside their parent message, so the delete action cleans up the files too — no separate attachment-scrubbing step is needed.

💡
Tip
See: AutoMod Actions → for what each action does, its required Discord permissions, and every action_config field.