Batch leave Discord servers you no longer need. Zero dependencies, single file, dry-run by default.
I had 166 Discord servers from the airdrop era — ZK, Arb, OP, Starknet, NFT, node, GameFi — with 30,000+ unread mentions. This script cleaned it down to 16 in under 2 minutes.
简体中文: README.zh-CN.md
git clone https://github.com/runesleo/discord-cleanup.git
cd discord-cleanup
# Set your Discord token (see "Get Your Token" below)
export DISCORD_TOKEN="your_token_here"
# See what you have
python discord_cleanup.py list --category
# Preview cleanup (dry-run, nothing happens)
python discord_cleanup.py cleanup
# Edit whitelist.json → add server IDs you want to keep
# Execute cleanup
python discord_cleanup.py cleanup --executeNo pip install, no requirements.txt, no virtual env. Just Python.
# List all servers
python discord_cleanup.py list
# List with auto-categorization (Airdrop/DeFi, NFT, GameFi, Trading, etc.)
python discord_cleanup.py list --category
# Interactive cleanup — dry-run first, shows what would be removed
python discord_cleanup.py cleanup
# Actually leave servers (requires typing "yes" to confirm)
python discord_cleanup.py cleanup --execute
# Leave specific servers by ID
python discord_cleanup.py leave <server_id> [<server_id> ...]Fetch all servers → Auto-categorize → Generate whitelist.json
↓
Edit whitelist (add IDs to keep)
↓
Run --execute → Confirm "yes" → Done
- Fetches all your servers and groups them by category
- Creates
whitelist.json— servers you own are auto-whitelisted - Dry-run by default: shows the plan, touches nothing
- You edit
whitelist.jsonto add servers worth keeping --executeleaves the rest, with a confirmation prompt
- Open Discord in your browser
- Press
F12→ Network tab - Click anything in Discord, find a request to
discord.com - Copy the
Authorizationheader value
export DISCORD_TOKEN="your_token_here"
# or
python discord_cleanup.py list --token "your_token_here"Security note: Your token grants full account access. Never commit it, never share it. If compromised, change your Discord password immediately (invalidates all tokens).
- Dry-run by default — nothing happens unless you pass
--execute - Confirmation required — must type
yesto proceed - Owned servers protected — auto-whitelisted, can't accidentally leave
- Rate limit handling — waits automatically when Discord throttles
- Whitelist persistence — saved to file, survives re-runs
- x-reader — Universal content reader for 7+ platforms
- claude-code-workflow — Battle-tested Claude Code workflow template
MIT
Leo (@runes_leo) — AI × Crypto independent builder. Trading on Polymarket, building data and trading systems with Claude Code and Codex.
leolabs.me — writing · community · open-source tools · indie projects · all platforms.
X Subscription — paid content weekly, or just buy me a coffee 😁
Learn in public, Build in public.