# Anti-invite

> Automatically remove Discord invite links

Anti-invite scans messages for Discord invite links, resolves each one, and removes the message unless it is exempt. It is a premium feature.

## Setup

Run `/anti-invite`. The command takes no options and opens a dashboard where you set the toggle, log channel, excluded channels and roles, member threshold, action and allowed servers.

<Cmd cmd="/anti-invite" />

## What it detects

It matches `discord.gg/...`, `discord.com/invite/...` and `discordapp.com/invite/...`, with or without `http` or `www`. Other link shorteners and vanity redirectors (for example `dsc.gg`) are not detected.

## Actions

<discord-messages class="not-prose">
	<discord-message profile="aethor">
		SomeUser, invite links are not allowed here.
	</discord-message>
</discord-messages>

- Delete (default): removes the message.
- Delete and warn: also posts a warning that deletes itself after 8 seconds.
- Delete and timeout: also times the member out for 10 minutes. This needs the Moderate Members permission.

The timeout length and warning lifetime are fixed and cannot be changed.

## Exemptions

A message is allowed if any of these is true, checked in order: anti-invite is off, the channel is excluded, the author has the **Anti-invite · Exempt** capability, the invite points to this server, the target server is on your allowed list, or the target server meets the member threshold you set.

You can also delegate **Anti-invite · Exempt** in [Permissions](/docs/permissions) to selected roles. The **Excluded roles** control in the `/anti-invite` Discord dashboard edits that same capability grant, so both surfaces use one rule. Those members can post invite links without Anti-invite actioning them.

## Limits and permissions

- Expired or invalid invites cannot be resolved, and those messages are deleted anyway.
- The member threshold is a "big servers are fine" allowlist. It defaults to 0, which means there is no minimum and every other resolvable invite is enforced. Set it above 0 to exempt target servers with at least that many members.
- If a message contains several links and one is not exempt, the message is removed.
- The bot needs Manage Messages. If it loses that permission in a channel, links there are silently left alone.
- If the bot loses Moderate Members after you pick the timeout action, messages are still deleted but the timeout is skipped.
- A log channel needs Embed Links and Send Messages, or logging is silently skipped.
- Enforcement shares the same rate limits as the rest of the bot. During a heavy raid it can stop acting once those limits are hit.
- You cannot add your own server to the allowed list.

After setup, test one invite from a server that should be blocked and one from a server that should be allowed. Check the log channel if you enabled logging.
