delete discord message in bulk
by @ghjbku
Use when user requests deleting multiple Discord messages or channel cleanup. Triggers on phrases like: - "delete [X] messages" - "purge [X] messages" - "cle...
clawhub install discord-bulk-message-deleteπ About This Skill
name: bulk message delete description: Use when user requests deleting multiple Discord messages or channel cleanup. Triggers on phrases like: - "delete [X] messages" - "purge [X] messages" - "clean up [channel]" - "remove old messages" - "clear the chat" - "bulk delete in #[channel]" Always use when intent to delete Discord messages is clear, even without specifying skill name.
Discord Bulk Message Purge Tool - Documentation
Overview
A Python script for deleting messages from Discord channels without requiring npm/discord.js dependencies. Uses only Python standard library + requests.
Location: discord-bulk-message-delete/scripts/discord-purge-tool.py (in the subfolder of the skill!)
Quick Start
1. Configure Bot Token
Create token.json in the workspace directory:
{
"token": "tokenhere"
}
OR set environment variable:
$env:DISCORD_TOKEN = "YOUR_BOT_TOKEN_HERE"
2. ask for confirmation
- run python scripts/discord-purge-tool.py purge to call dry-run mode
- ask from the user if they really want to delete x amount of messages in the current channel
3. Run the Tool
From this skill's directory:
# Delete last 5 messages
python scripts/discord-purge-tool.py --delete --channel-id
OR
python scripts/discord-purge-tool.py -d --channel-id Delete custom count
python scripts/discord-purge-tool.py purge 25 --delete --channel-id
OR
python scripts/discord-purge-tool.py purge 25 -d --channel-id Larger purge (handles batches automatically)
python scripts/discord-purge-tool.py purge 200 --delete --channel-id
OR
python scripts/discord-purge-tool.py purge 200 -d --channel-id
Usage Examples
Typical User Requests (I auto-detect intent):
Script Commands:
# run in 'scout/dry-run' mode
python scripts/discord-purge-tool.py purge --channel-id
Delete last X messages (default: 5)
python scripts/discord-purge-tool.py purge -d --channel-id
Features
Rate Limiting
Discord enforces:
The tool handles this transparently, so you don't need to worry about it.
Permissions Required
Your Discord bot must have MANAGE_MESSAGES permission in target channels:
1. Go to your Discord server settings 2. find the role your bot uses 3. add "manage Messages" permission
Error Codes
Configuration
token.json
{
"token": "YOUR_BOT_TOKEN_HERE"
}
Or environment variable:
$env:DISCORD_TOKEN = "YOUR_BOT_TOKEN_HERE"
Command Reference
| Command | Description |
|---------|-------------|
| python scripts/discord-purge-tool.py purge | dry-run last N messages |
| python scripts/discord-purge-tool.py purge 10 -d --channel-id | Delete last 5 (default) |
| python scripts/discord-purge-tool.py purge 10 --delete --channel-id | Delete last 10 |
Troubleshooting
"403 Forbidden" error
The bot doesn't have MANAGE_MESSAGES permission. Fix by:
1. Adding permissions via Discord settings
2. OR setting DISCORD_TOKEN env variable and running from this skill's directory
"400 Bad Request" error
Check that:
Notes
scripts/discord-purge-tool.pyπ‘ Examples
1. Configure Bot Token
Create token.json in the workspace directory:
{
"token": "tokenhere"
}
OR set environment variable:
$env:DISCORD_TOKEN = "YOUR_BOT_TOKEN_HERE"
2. ask for confirmation
- run python scripts/discord-purge-tool.py purge to call dry-run mode
- ask from the user if they really want to delete x amount of messages in the current channel
3. Run the Tool
From this skill's directory:
# Delete last 5 messages
python scripts/discord-purge-tool.py --delete --channel-id
OR
python scripts/discord-purge-tool.py -d --channel-id Delete custom count
python scripts/discord-purge-tool.py purge 25 --delete --channel-id
OR
python scripts/discord-purge-tool.py purge 25 -d --channel-id Larger purge (handles batches automatically)
python scripts/discord-purge-tool.py purge 200 --delete --channel-id
OR
python scripts/discord-purge-tool.py purge 200 -d --channel-id
βοΈ Configuration
token.json
{
"token": "YOUR_BOT_TOKEN_HERE"
}
Or environment variable:
$env:DISCORD_TOKEN = "YOUR_BOT_TOKEN_HERE"
π Tips & Best Practices
scripts/discord-purge-tool.py