A Discord bot that watches for users posting images with specific SHA256 checksums, then automatically bans/kicks them and deletes all of their messages.
- Monitors all image attachments posted in the guild
- Computes SHA256 checksums server-side (streaming — no temp files)
- Matches against a configurable watchlist persisted to
checksums.json - Configurable action:
ban(default) orkick - Deletes every message from the matched user across all text channels
- Slash commands for management (require
Manage Messagespermission)
- Node.js 20+
- A Discord account and a server where you have
Manage Serverpermission
- Open the Discord Developer Portal and log in.
- Click New Application in the top-right corner.
- Enter a name (e.g. "Image Guard") and click Create.
- In the left sidebar, click Bot.
- Click Reset Token and confirm. Copy the token immediately — it looks like
MTIz.... You won't be able to see it again. Paste it somewhere safe (you'll add it to.envlater).
Still on the Bot page, scroll down to Privileged Gateway Intents and toggle ON:
- MESSAGE CONTENT INTENT — needed to read attachments on messages
- SERVER MEMBERS INTENT — needed to kick/ban members
Click Save Changes.
- In the left sidebar, click Installation.
- Under Installation Contexts, make sure Guild Install is checked.
- Under Default Install Settings > Guild Install, add these scopes:
botapplications.commands
- When you select
bot, a permissions dropdown appears. Select:Kick MembersBan MembersManage MessagesView ChannelsSend MessagesRead Message History
- Click Save Changes.
If Guild Install is not enabled here, the bot will never appear in the server member list even after authorizing via the OAuth2 URL.
- In the left sidebar, click General Information.
- Copy the Application ID (also called Client ID). You'll need this for
.env.
- In the left sidebar, click OAuth2 > URL Generator.
- Under Scopes, check:
botapplications.commands
- Under Bot Permissions, check:
Kick MembersBan MembersManage MessagesView ChannelsSend MessagesRead Message History
- Copy the generated URL at the bottom of the page.
- Open it in your browser, select your server, and click Authorize.
- Open Discord and go to User Settings > Advanced.
- Toggle Developer Mode ON.
- Right-click your server name in the sidebar and click Copy Server ID (or Copy ID).
cp .env.example .envFill in .env:
| Variable | Description |
|---|---|
DISCORD_TOKEN |
Bot token from step 2 |
CLIENT_ID |
Application ID from step 4 |
GUILD_ID |
Server ID from step 6 |
npm install
npm run dev # development with hot-reload
# or
npm run build && npm start # productionCreated automatically on first run. You can also edit it directly:
{
"checksums": [
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"
],
"action": "ban"
}The action field is either "ban" or "kick".
| Command | Description |
|---|---|
/add-checksum <sha256hex> |
Add a checksum to the watchlist |
/remove-checksum <sha256hex> |
Remove a checksum |
/list-checksums |
Show all watched checksums |
/set-action ban|kick |
Set the action to take |
All commands require the Manage Messages permission in the server.
- Go to the Installation page in the Developer Portal.
- Confirm Guild Install is checked under Installation Contexts.
- Confirm the Default Install Settings for Guild Install include both
botandapplications.commandsscopes. - Re-generate the invite URL from OAuth2 > URL Generator and re-invite the bot.
Ensure you have a .env file (not .env.example) with all fields filled in. See step 8.
sha256sum image.pngmacOS:
shasum -a 256 image.png