# Flood protection

Source: https://righteousbot.dev/docs/protection/flood-protection/

Catch someone posting too fast, or posting the same thing over and over, and clean up the whole burst.

Flood protection watches how *much* one person posts, not what is in it: **rate** (too many messages, too
fast) and **duplicate** (the same message again and again). Both start **off**, and configuring them is
**Server Owner** only, because they can ban someone automatically. For what a message says, use
[message filters](/docs/protection/message-filters/); for a channel nobody should post in, the
[trap channel](/docs/protection/trap-channel/).

## See what is running [#see-what-is-running]

[`,antispam list`](/commands/server-tools/antispam/#antispam-list) shows everything at once. If it fires on
nobody, start here: both detectors ship off.

<CommandBlock syntax=",antispam list" />

<DiscordEmbed caption="The summary on a server with both rules on, one channel ignored, and everything else at its default." invokedWith=",antispam list" color="#2F3136" title="Anti-Spam" description="&#x22;**Rate** on — 6 messages / 5s → timeout\n**Duplicate** on — 4 identical / 30s → timeout\n**Escalation** off\n**Purge burst** on · **Ignore commands** on · **Timeout** 5m\n**Ignored channels** #memes&#x22;" footer="Righteous" />

## Catch someone posting too fast [#catch-someone-posting-too-fast]

[`,antispam rate`](/commands/server-tools/antispam/#antispam-rate) counts messages **across the whole
server**, not per channel, so one message in fifteen channels still trips it.

<CommandBlock syntax=",antispam rate <on|off> [++punish <p>] [++threshold <n>] [++window <s>] [++duration <t>]" example=",antispam rate on ++threshold 6 ++window 5 ++punish timeout" />

| Flag          | Means                           | Accepts                                                     | Default   |
| ------------- | ------------------------------- | ----------------------------------------------------------- | --------- |
| `++punish`    | what happens when it trips      | `warn`, `timeout`, `mute`, `jail`, `kick`, `softban`, `ban` | `timeout` |
| `++threshold` | messages that trip it           | 3 to 50                                                     | 6         |
| `++window`    | seconds they must arrive inside | 2 to 120                                                    | 5         |
| `++duration`  | how long a timeout lasts        | e.g. `5m`, `1h`                                             | `5m`      |

## Catch someone repeating themselves [#catch-someone-repeating-themselves]

[`,antispam duplicate`](/commands/server-tools/antispam/#antispam-duplicate) takes the same flags except
`++duration`, with a threshold default of 4 and a window default of 30.

<CommandBlock syntax=",antispam duplicate <on|off> [++punish <p>] [++threshold <n>] [++window <s>]" example=",antispam duplicate on ++threshold 4 ++window 30" />

The messages do not have to be consecutive: posting something else in between does not reset the count.
Capitals, extra spaces and invisible characters are ignored, and lookalike alphabets are folded back, so
`𝗳𝗿𝗲𝗲 𝗻𝗶𝘁𝗿𝗼` and `free nitro` match. It is not fuzzy beyond that: `yes` and `yea` differ. Messages with
no text (a bare image) are ignored.

## Try it without punishing anyone [#try-it-without-punishing-anyone]

Use `++punish warn` for the first week. Nothing happens to the member, but you still get a log entry each
time it would have fired.

<CommandBlock syntax=",antispam rate on ++punish warn" />

## Clean up the whole burst [#clean-up-the-whole-burst]

[`,antispam settings`](/commands/server-tools/antispam/#antispam-settings) controls what happens around a
trip.

<CommandBlock syntax=",antispam settings [++purge <on|off>] [++commands <on|off>] [++duration <t>]" example=",antispam settings ++purge on" />

| Flag         | Means                                                      | Default |
| ------------ | ---------------------------------------------------------- | ------- |
| `++purge`    | delete the whole burst, not one message                    | `on`    |
| `++commands` | don't count Righteous commands, so `,fm` six times is fine | `on`    |
| `++duration` | how long a timeout lasts                                   | `5m`    |

<Callout type="warn">
  Custom command aliases are not recognised: invoking one counts as an ordinary message. Exempt a channel
  if that becomes a problem.
</Callout>

## Exempt a channel [#exempt-a-channel]

[`,antispam ignore`](/commands/server-tools/antispam/#antispam-ignore) is the first thing to reach for
after a false positive. Naming a **category** exempts everything in it, threads included.

<CommandBlock syntax=",antispam ignore <add|remove|list> [#channel]" example=",antispam ignore add #spam" />

## Punish repeat offenders harder [#punish-repeat-offenders-harder]

[`,antispam escalation`](/commands/server-tools/antispam/#antispam-escalation) gives a repeat offender a
harsher punishment. Offences are remembered in the punishment history, so it survives a restart.

<CommandBlock syntax=",antispam escalation <on|off> [++punish <p>] [++days <n>]" example=",antispam escalation on ++punish ban ++days 7" />

| Flag       | Means                          | Accepts        | Default |
| ---------- | ------------------------------ | -------------- | ------- |
| `++punish` | what a repeat offender gets    | any punishment | `ban`   |
| `++days`   | how far back an offence counts | 1 to 90        | 7       |

## Who never gets caught [#who-never-gets-caught]

The server owner, the bot owner, and anyone on your
[`,filter whitelist`](/docs/protection/message-filters/) for every filter or for `spam` (an entry scoped to
links or invites doesn't count). It's one list shared with the message filters.
**Moderator permissions alone do not exempt anyone**: put your staff role on the whitelist if you want
them exempt. That is deliberate, so a protection every mod is invisible to cannot hide a misconfiguration.

## Start over [#start-over]

[`,antispam reset`](/commands/server-tools/antispam/#antispam-reset) clears everything and turns both
detectors off.

<CommandBlock syntax=",antispam reset" />

## Common issues [#common-issues]

**It fires on the wrong people.** In order: `,antispam ignore add` the busy channel, raise the threshold or
shorten the window (a very active general may want `++threshold 10 ++window 5`), switch to `++punish warn`
while you tune, then whitelist your staff role if the false positives are moderators.

**It never fires.** Run `,antispam list`: turning the feature "on" means turning a *detector* on.
