Skip to main content

Anti-Raid

Ban joining members who match a known raid profile, and give roles and a welcome message to members who finish Discord's membership screening.

Why Use This Feature?

  1. Bans joins that match avatar hashes or usernames from past raids, before they can post or message your members.
  2. Reports each ban with the signals that matched, so moderators can see why the bot acted.
  3. Hands out entry roles once a member accepts your rules, so new members get access without waiting for a moderator.

How It Works

The feature has two parts, and you can use either one or both.

Raid Bans

  • What it checks — When a member joins, the bot compares their avatar hash with your avatar list, and their username and display name with your username list.
  • How names match — Names match when they are equal after the bot turns styled and fullwidth letters into plain ones, trims outer spaces, and lowercases them. Accents, extra inner spaces, and partial names still don't match.
  • What it does — Any match bans the member, with the matched signals as the ban reason in the server's audit log, such as Anti-raid: configured username.
  • What it posts — After each ban, the bot posts one plain-text report to the alert channel, naming the member and the signals that matched.
  • When Discord refuses the ban — The report says the bot couldn't ban the member and adds Discord's error, so a moderator can step in.

The avatar check uses the member's main avatar, not a server-specific avatar, and a member without an avatar never matches.

These reports post only in your Discord alert channel, while Notifications sends alerts about the bot itself to your phone or inbox.

New Member Access

  • When it runs — When Discord marks a member as having completed membership screening.
  • What it does — The bot adds the gate roles the member doesn't have yet, then posts the gate message in the gate channel.
  • All or nothing — If any gate role is missing, managed by an integration, or at or above the bot's highest role, the bot adds no roles and posts nothing.

The gate message posts even when the member already had every gate role.

Requirements

Settings

FieldDescription
Raid bans → Channel (auto-ban.channel)The alert channel for ban reports, required for raid bans.
Raid bans → Avatars (auto-ban.avatars)1 to 100 avatar hashes to match exactly.
Raid bans → Usernames (auto-ban.usernames)1 to 100 names to compare with each joining member's username and display name.
New member access → Channel (membership-gate.channel)The channel where the gate message posts.
New member access → Roles (membership-gate.roles)1 to 25 roles to give members who finish screening.
New member access → Message (membership-gate.payload)Optional Text of up to 2,000 characters and Footer → Footer text of up to 1,000, posted as two lines of plain text.

Raid bans need at least one avatar or username. Without a message, the gate posts "You have successfully passed the membership gate."

Mentions in the gate message don't notify anyone, so the new member gets no ping.

Example

Anti-raid settings
json
{
  "auto-ban": {
    "channel": { "channel-id": "123456789012345678" },
    "usernames": [{ "username": "Discord Support" }]
  },
  "membership-gate": {
    "channel": { "channel-id": "123456789012345679" },
    "roles": [{ "role-id": "223456789012345678" }],
    "payload": { "content": "Welcome to %GUILD_NAME%, %MEMBER_MENTION%!" }
  }
}

Message Variables

The gate message supports these message variables. The ban report text is fixed and has none.

VariableBecomes
%GUILD_NAME%The server's name
%MEMBER_MENTION%A mention of the member
%YEAR%The current year in UTC

Limits

  • Lists — 100 avatars, 100 usernames, and 25 gate roles.
  • Message length — The ban report and the gate message are cut at 2,000 characters, and the ban reason at 512.

Troubleshooting

  • A raid account wasn't banned — Check the exact name, because matching ignores only letter case, outer spaces, and styled or fullwidth letters. Avatar matching uses the member's main avatar hash.
  • "Couldn't ban a joining member who matched anti-raid signals." — The report's Error line has Discord's reason. Usually the bot is missing Ban Members, or the member has a role at or above the bot's highest role.
  • The gate didn't run for a member — The bot sees screening only for members it has seen since its last reconnect, so a member who joined before a reconnect and finishes screening after it is missed.
  • "Membership-gate role … is unavailable or not manageable." — This log entry means a gate role was deleted, is managed by an integration, or sits above the bot's highest role.
  • "Fix this feature's settings before turning it on." — Imported settings may have no alert channel, so choose one under Raid bans → Channel and save.
  • Example role 000000000000000000 — Replace the placeholder role, the placeholder avatar hash, and both example channels from the example settings before you turn the feature on.

Changes from the legacy bot

The legacy bot banned members whose avatar or exact username matched, without posting anything in Discord. The rewrite also checks display names, ignores letter case and styled letters, and reports each ban in an alert channel set in auto-ban.channel, so an imported legacy feature without one stays off until you choose a channel.

The gate message is now plain text with the footer on a second line, and %YEAR% uses UTC instead of the legacy time zone setting.