Discord moderation bot that stops spam
It deletes spam, times out the person behind it and logs who it was, even when they post through an app on their own account.
@everyone Free Nitro for everyone who joins in the next hour discord.gg/nitro-drop
Anything more their apps post in the next 15 minutes is deleted too.
- Plan
- Free, always on
- Setup
- A token, then /securitycheck
- Privileged intents
- Server Members, Message Content
- Spam protection
- On from the start
What the moderation bot does
Spam stopped on its own
It deletes the spam, times the person out for a day and logs it with a copy of the message. Staff are never checked, and every log entry has a Remove timeout button for mistakes.
App spam, traced to a person
Members can run apps installed on their own Discord account and have them post in your channels, and Discord does not show who ran them. The bot reads it from the message and acts on that person.
Hacked accounts caught
The same message in 3 channels within 30 seconds is deleted everywhere, and the member gets a direct message telling them to change their password.
A security check with fix buttons
/securitycheck finds what lets spam in, such as Use External Apps left on for everyone, and fixes it once you have seen the change. /automod-setup blocks invite links to other servers.
The everyday tools
Warnings that are remembered, timeouts, kicks, bans, purges and slowmode, every action written to your mod log.
Set it up
- 1
Create the bot
At discord.com/developers, New Application, then Bot and Reset Token. Copy the token.
- 2
Turn on the intents
Under Bot, Privileged Gateway Intents: Server Members, which it needs, and Message Content, which lets it read messages. Without Message Content it cannot spot copy-paste spam or judge spam by what it says.
- 3
Invite it
With the link in the box, your Application ID in place of
YOUR_APP_ID. It asks for every permission the bot uses. Then drag the bot's role above the roles your members have. - 4
Deploy it
Press Deploy free, pick the Moderation Bot template and paste the token.
- 5
Close the holes
Run
/securitycheckand use its fix buttons, then/automod-setup.
Commands
Spam protection and security, for Manage Server
- /securitycheck
- Lists risky server settings, each with a fix button that shows what it will change and asks first.
- /automod-setup [allow]
- Creates Discord AutoMod rules: invite links to other servers are blocked, your own and any you list stay allowed, and so are messages with more than 10 mentions.
- /protection [app_spam] [copy_spam] [timeout_minutes] [ban]
- Shows the automatic spam protection and changes it: turn a check off, set the timeout, or ban instead.
Moderation
- /warn user reason
- Warns the member by direct message and remembers it.
- /warnings user
- The member's warnings.
- /clearwarnings user
- Forgets them.
- /timeout user minutes [reason]
- Times the member out, up to four weeks.
- /untimeout user
- Ends a timeout.
- /kick user [reason]
- Kicks the member.
- /ban user [reason] [delete_days]
- Bans the member, deleting their recent messages if you like.
- /unban user_id
- Lifts a ban.
- /purge amount [from]
- Deletes the last messages in the channel. Discord keeps ones older than two weeks.
- /slowmode seconds
- Slows the channel down. 0 turns it off.
- /modlog [#channel]
- Where actions are logged.
Who may use what follows your server's own permissions: someone without Ban Members does not see /ban.
Environment variables
They live in the table on the bot's page in the panel, values masked once saved. The template's form asks for the ones it needs when you deploy.
| Variable | Needed | What it is |
|---|---|---|
| DISCORD_TOKEN | Required | Your bot token. |
| MODLOG_CHANNEL_ID | Optional | The mod log, if you would rather not use /modlog or the fix button that creates a private #mod-log. |
Which plan it needs
The free plan runs it, always on. Move it to Starter when your server is large and busy: the usage chart on its page shows how close it runs to its memory.
Free
Recommended$0
No card
- 256 MB and a quarter of a CPU, always on
- No card: one free bot or app per person
- No renewals. Only a bot with no network traffic for 7 days is stopped
Starter
$2/mo
or $20 a year
- 1 GB of memory and a full vCPU
- Never stopped for being quiet
- You pick the region it runs in
Running more than one? Standard carries two bots or apps for $3 a month and Pro four for $6, on one bill with your game servers. Every plan
Frequently asked questions
What is app spam?
Discord lets members install apps on their own account and use them in any server, yours included. A spammer runs one to drop invite links in every channel, and Discord shows the app's name, not who ran it. The bot reads who ran it from the message, removes the posts and times out that person. /securitycheck can also turn off Use External Apps, which keeps those apps from posting at all.
Will it ban someone by mistake?
It does not ban unless you tell it to. It times the person out for a day, and every log entry has a Remove timeout button. Banning instead is a /protection setting, off until you turn it on, and the Ban button in a log entry asks before it bans.
Does it need Message Content?
Server Members is required. Message Content is recommended: without it the bot cannot read messages, so the copy-paste check is skipped and app spam is caught only by how many channels it reaches. Everything else works.
I run an older version. How do I get the spam protection?
Redeploy it in the panel, open the invite link again to grant Manage Roles and Manage Server, and turn on Message Content. Warnings and settings carry over.
Is the moderation bot free?
Yes. It runs on the free plan, always on, with no card. One bot or app is free per person; a second one needs a paid plan, from $2 a month for one or $3 for two.
More ready-made bots
Bringing your own code instead? How a bot deploys from GitHub
Keep spam out of your server
Your first bot is free, with no card. It logs in within a minute.