# Antiraid

Source: https://righteousbot.dev/docs/protection/antiraid/

Punish a burst of joins, gate young accounts, and lock the server down until the wave passes.

Anti-raid watches the door: a burst of joins, brand-new accounts, accounts with no avatar. For what your
existing members do, see [anti-nuke](/docs/protection/antinuke/). It needs **Administrator**, except
[`,antiraid antijoin`](/commands/server-tools/antiraid/#antiraid-antijoin), which is **Server Owner** only.

## Turn on burst detection [#turn-on-burst-detection]

[`,antiraid raid`](/commands/server-tools/antiraid/#antiraid-raid) counts joins and responds when too many
land too close together. Everybody in the burst is punished, not just the joiner who crossed the line.

<CommandBlock syntax=",antiraid raid <on|off> [++punish <p>] [++joins <n>] [++window <s>] [++duration <s>] [++lockdown <on|off>]" example=",antiraid raid on ++punish ban ++joins 10 ++window 10" />

| Flag         | Means                         | Accepts                                                     | Default |
| ------------ | ----------------------------- | ----------------------------------------------------------- | ------- |
| `++punish`   | what happens to each joiner   | `warn`, `timeout`, `mute`, `jail`, `kick`, `softban`, `ban` | `ban`   |
| `++joins`    | joins that trip it            | 2 to 50                                                     | 10      |
| `++window`   | seconds they must land inside | 5 to 120                                                    | 10      |
| `++duration` | how long it stays armed       | 60 to 3600 seconds                                          | 600     |
| `++lockdown` | also raise verification       | `on` / `off`                                                | `off`   |

Every join while armed pushes the disarm time forward, so `duration` counts from the last arrival. When
things go quiet it disarms and posts a summary.

<DiscordEmbed caption="The incident burst detection posts when it trips, with the example settings above and lockdown off." color="#dc141a" author="Anti-Raid — Righteous" title="Raid Detected" description="&#x22;10 joins inside 10s (threshold 10)\nPunishment: ban&#x22;" footer="Righteous · 987654321098765432" />

Try it first with `++punish warn`: it posts the incident and does nothing to anybody.

## Pick a punishment [#pick-a-punishment]

| Punishment     | Bot needs        | Good for                                                                                                                                                                                                    |
| -------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `warn`         | nothing          | A dry run                                                                                                                                                                                                   |
| `timeout`      | Moderate Members | A likely false positive. One hour, reversible                                                                                                                                                               |
| `mute`, `jail` | Manage Roles     | Servers with the role set by [`,config muterole`](/commands/server-tools/config/#config-muterole) or [`,config jailrole`](/commands/server-tools/config/#config-jailrole). Without one it cannot be applied |
| `kick`         | Kick Members     | Rarely right for a raid: they can rejoin                                                                                                                                                                    |
| `softban`      | Ban Members      | Clears their messages, then unbans                                                                                                                                                                          |
| `ban`          | Ban Members      | A confident raid                                                                                                                                                                                            |

## Gate accounts as they join [#gate-accounts-as-they-join]

Three rules run on every join, independently of burst detection. Each takes `++punish` from the list above.

| Rule                                                             | Acts on                                                        | Extra flag    | Default punishment |
| ---------------------------------------------------------------- | -------------------------------------------------------------- | ------------- | ------------------ |
| [`antialt`](/commands/server-tools/antiraid/#antiraid-antialt)   | Accounts younger than `++threshold` days (1 to 365, default 3) | `++threshold` | `kick`             |
| [`antipfp`](/commands/server-tools/antiraid/#antiraid-antipfp)   | Joins with no profile picture                                  | none          | `ban`              |
| [`antijoin`](/commands/server-tools/antiraid/#antiraid-antijoin) | Everyone who joins (**Server Owner**)                          | none          | `ban`              |

<CommandBlock syntax=",antiraid antialt <on|off> [++punish <p>] [++threshold <days>]" example=",antiraid antialt on ++punish kick ++threshold 7" />

<Callout type="warn" title="antijoin catches everybody">
  There is no threshold and no exception for a legitimate new member. Turn it off when you are done:
  leaving it on is the most common way to quietly stop a server growing.
</Callout>

## Lock the server down during a raid [#lock-the-server-down-during-a-raid]

`++lockdown on` on the `raid` rule raises verification to High while the response is armed, then puts it
back. It is the only anti-raid action whose effect outlives the incident.

<CommandBlock syntax=",antiraid raid on [++lockdown <on|off>]" example=",antiraid raid on ++punish ban ++lockdown on" />

The old level is recorded before it is raised, so a restart mid-raid does not strand you on High. The bot
only lowers it again if the level is still what it set: if a human changed it, it is left alone. Lockdown
is skipped if the bot lacks **Manage Server** or verification is already High or above.

## Unstick a server left on High [#unstick-a-server-left-on-high]

[`,antiraid unlock`](/commands/server-tools/antiraid/#antiraid-unlock) (**Administrator**) puts it back,
forcing past those checks. With no record of a raise it refuses rather than guess a level.

<CommandBlock syntax=",antiraid unlock" />

## Review and reset [#review-and-reset]

[`,antiraid list`](/commands/server-tools/antiraid/#antiraid-list) shows every rule;
[`,antiraid reset`](/commands/server-tools/antiraid/#antiraid-reset) turns all of them off. The Anti-Raid
page of the [`,config`](/commands/server-tools/config/) panel edits the same rules. Incidents post to the
[`,antinuke log`](/commands/server-tools/antinuke/#antinuke-log) channel, falling back to
[`,config logchannel`](/commands/server-tools/config/#config-logchannel).

## Common issues [#common-issues]

**Nothing happened when people joined.** The punishment's permission is missing (a `ban` rule with no Ban
Members does nothing), or `mute`/`jail` has no role set.

**A big raid punished fewer people than joined.** One incident issues at most **200** punishments, and
the summary says when it hit the cap. At most **two** run at a time per server, so a big wave takes
longer to work through than it took to arrive. Nothing in flight is dropped.

**The server is still on High after the raid.** Run `,antiraid unlock`.

**Real members are caught by `antialt`.** Lower `++threshold`, or use `timeout` so a mistake is cheap.

**A restart happened mid-raid.** Verification is restored, but the punishment sweep does not resume.
