Overview
Discord is a popular platform for community chat. This guide shows you how to create a Discord bot and connect it to AgentClaw.
Step 1: Create Discord Application
- Go to Discord Developer Portal
- Click "New Application"
- Enter a name for your bot
- Click "Create"
Step 2: Create Bot User
- In your application, go to the "Bot" section
- Click "Add Bot"
- Confirm by clicking "Yes, do it!"
- Under "Token", click "Reset Token"
- Copy the token - save this securely!
Step 3: Configure Bot Permissions
Under "Privileged Gateway Intents", enable:
- ✓ Message Content Intent (required to read messages)
- ✓ Server Members Intent (optional, for member info)
- ✓ Presence Intent (optional, for user status)
Click "Save Changes"
Step 4: Add Bot Token to AgentClaw
- Go to your AgentClaw instance configuration
- Add environment variable:
- Name:
DISCORD_BOT_TOKEN - Value: Paste your bot token
- Name:
- Save and restart your instance
Step 5: Invite Bot to Your Server
- In Discord Developer Portal, go to "OAuth2" → "URL Generator"
- Under "Scopes", select:
- ✓
bot - ✓
applications.commands
- ✓
- Under "Bot Permissions", select:
- ✓ Send Messages
- ✓ Read Messages/View Channels
- ✓ Read Message History
- ✓ Add Reactions (optional)
- Copy the generated URL
- Open the URL in your browser
- Select the server to add the bot to
- Click "Authorize"
Step 6: Test Your Bot
- Check your AgentClaw logs - bot should connect
- In Discord, @mention your bot:
@YourBot hello - Bot should respond with AI-generated message
Bot Behavior in Discord
Your bot will respond to:
- Direct messages (DMs)
- @mentions in channels
- Replies to bot messages
- Messages in channels where bot has permissions
Troubleshooting
Bot Shows as Offline
- Check instance is running in AgentClaw
- Verify
DISCORD_BOT_TOKENis correct - Check logs for connection errors
- Ensure Message Content Intent is enabled
Bot Online But Not Responding
- Ensure bot has permission to read/send messages in channel
- Try @mentioning the bot directly
- Check AI provider API key is valid
- Review logs for errors
"Invalid Token" Error
- Regenerate token in Discord Developer Portal
- Update
DISCORD_BOT_TOKENin AgentClaw - Restart instance
Next Steps
- Learn about Telegram bot integration
- Explore switching AI providers
- Read about monitoring with logs