Discord Setup
Overview
Section titled “Overview”Run Clawdbot as a Discord bot to bring Claude’s intelligence to your servers. Perfect for communities, development teams, or personal use.
Prerequisites
Section titled “Prerequisites”- Clawdbot installed
- Discord account
- Server where you have “Manage Server” permission
-
Create a Discord Application
- Go to Discord Developer Portal
- Click “New Application”
- Name it (e.g., “Clawdbot”)
- Navigate to “Bot” section
- Click “Add Bot”
-
Get the Bot Token
- In Bot section, click “Reset Token”
- Copy and save the token securely
-
Enable Required Intents
In Bot section, enable:
- ✅ Message Content Intent
- ✅ Server Members Intent (optional)
- ✅ Presence Intent (optional)
-
Generate Invite Link
- Go to OAuth2 → URL Generator
- Scopes:
bot,applications.commands - Permissions:
Send Messages,Read Message History,Embed Links,Attach Files - Copy the generated URL
-
Add Bot to Server
- Open the invite URL
- Select your server
- Authorize
-
Configure Clawdbot
Edit
.env:Terminal window DISCORD_ENABLED=trueDISCORD_BOT_TOKEN=your_token_here -
Start Clawdbot
Terminal window python -m clawdbot
Configuration Options
Section titled “Configuration Options”# RequiredDISCORD_BOT_TOKEN=your_token_hereDISCORD_ENABLED=true
# Rate limiting per user per channelDISCORD_RATE_LIMIT=15
# Prefix for commands (if not using slash commands)DISCORD_PREFIX=!
# Use slash commandsDISCORD_SLASH_COMMANDS=true
# Respond to DMsDISCORD_DM_ENABLED=true
# Respond in all channels or only specific onesDISCORD_ALLOWED_CHANNELS=123456789,987654321
# Require mention to respondDISCORD_MENTION_ONLY=false
# Admin user IDsDISCORD_ADMIN_USERS=123456789Features
Section titled “Features”Slash Commands
Section titled “Slash Commands”Modern Discord bots use slash commands:
| Command | Description |
|---|---|
/chat [message] | Chat with Clawdbot |
/reset | Clear your conversation history |
/help | Show available commands |
/settings | User preferences |
Text Commands
Section titled “Text Commands”Traditional prefix-based commands:
!ask What's the meaning of life?!reset!helpChannel Modes
Section titled “Channel Modes”Public Channel: Everyone sees the conversation
DISCORD_MENTION_ONLY=true # Only respond when @mentionedThread Support: Auto-create threads for conversations
DISCORD_USE_THREADS=trueDM Mode: Private conversations via direct message
DISCORD_DM_ENABLED=trueMedia Support
Section titled “Media Support”| Media Type | Receive | Send |
|---|---|---|
| Text | ✅ | ✅ |
| Images | ✅ | ✅ |
| Files | ✅ | ✅ |
| Embeds | - | ✅ |
| Voice | ❌ | ❌ |
Rich Embeds
Section titled “Rich Embeds”Clawdbot formats responses with Discord embeds:
# Example embed format{ "title": "Response", "description": "Claude's answer here...", "color": 0x5865F2, "footer": {"text": "Powered by Claude"}}Advanced Configuration
Section titled “Advanced Configuration”Multiple Servers
Section titled “Multiple Servers”Clawdbot works across all servers it’s invited to. Configure per-server settings:
# Whitelist specific serversDISCORD_ALLOWED_GUILDS=123456789,987654321
# Or blacklistDISCORD_BLOCKED_GUILDS=111111111Role-Based Access
Section titled “Role-Based Access”Restrict bot usage to specific roles:
DISCORD_REQUIRED_ROLE=Clawdbot User# Or by role IDDISCORD_REQUIRED_ROLE_ID=123456789Custom Status
Section titled “Custom Status”Set the bot’s status message:
DISCORD_STATUS=Chatting with ClaudeDISCORD_STATUS_TYPE=playing # playing, watching, listening, competingActivity Logging
Section titled “Activity Logging”Log all interactions for moderation:
DISCORD_LOG_CHANNEL=123456789 # Channel ID for logsDISCORD_LOG_LEVEL=all # all, commands, errorsTroubleshooting
Section titled “Troubleshooting”Bot Shows Offline
Section titled “Bot Shows Offline”- Verify token is correct
- Check Clawdbot logs:
Terminal window LOG_LEVEL=DEBUG python -m clawdbot - Ensure intents are enabled in Developer Portal
- Restart Clawdbot
”Missing Access” Error
Section titled “”Missing Access” Error”Bot lacks permissions. Re-invite with correct permissions:
- Send Messages
- Read Message History
- Embed Links
- Attach Files
- Use Slash Commands
Bot Not Responding to Messages
Section titled “Bot Not Responding to Messages”- Check Message Content Intent is enabled
- If using
DISCORD_MENTION_ONLY=true, ensure you’re mentioning the bot - Verify channel is in
DISCORD_ALLOWED_CHANNELS(if set) - Check rate limits
Slash Commands Not Appearing
Section titled “Slash Commands Not Appearing”- Slash commands take up to 1 hour to register globally
- For instant updates, use guild-specific commands:
Terminal window DISCORD_SLASH_COMMANDS_GUILD=123456789 - Re-invite bot with
applications.commandsscope
High Latency
Section titled “High Latency”- Check Clawdbot server location vs Discord servers
- Reduce response length
- Consider sharding for large deployments
Security Considerations
Section titled “Security Considerations”- Never share your bot token
- Use
DISCORD_ALLOWED_GUILDSto prevent unauthorized server additions - Implement role-based access for public servers
- Monitor logs for abuse
- Rate limit to prevent spam
Example Interactions
Section titled “Example Interactions”DM Conversation
Section titled “DM Conversation”User: Hi! Can you help me with Python?Clawdbot: Hello! I'd be happy to help with Python. What would you like to know?
User: How do I read a JSON file?Clawdbot: Here's how to read a JSON file in Python: ```python import json with open('data.json', 'r') as f: data = json.load(f)### Server Channel@User: @Clawdbot what’s the best sorting algorithm? @Clawdbot: The “best” sorting algorithm depends on your use case: • Quick sort: O(n log n) average, great general purpose • Merge sort: O(n log n) guaranteed, stable • Radix sort: O(nk) for integers …
### Slash Command/chat message:Explain recursion in one sentence Clawdbot: Recursion is when a function calls itself to solve a problem by breaking it into smaller instances of the same problem.
## Next Steps
- Add more channels: [Telegram](/channels/telegram/), [Slack](/channels/slack/)- Learn about [plugins](/concepts/plugins/) for custom commands- Set up [webhooks](/gateway/configuration/) for integrations