Overview
The Discord integration allows your elizaOS agent to interact with users on Discord servers through a bot. Your agent can send messages, react to content, manage channels, create polls, handle moderation tasks, and more.Prerequisites
Before setting up Discord integration, you need:- A Discord account
- A Discord server where you have admin permissions
- A Discord application and bot token from the Discord Developer Portal
Setup
botapplications.commands(for slash commands)
Send MessagesRead Message HistoryAdd ReactionsManage Messages(for editing/deleting)- Additional permissions based on your use case
# Required
DISCORD_BOT_TOKEN=your_bot_token_here
# Optional - for enhanced functionality
DISCORD_APPLICATION_ID=your_application_id_here
Configuration
Environment Variables
The Discord integration supports the following environment variables:| Variable | Required | Description |
|---|---|---|
DISCORD_BOT_TOKEN | Yes | Your Discord bot token from the Developer Portal |
DISCORD_APPLICATION_ID | No | Your application ID for enhanced features |
DISCORD_TOKEN→DISCORD_BOT_TOKENDISCORD_API_TOKEN→DISCORD_BOT_TOKEN
Character Settings
You can configure Discord-specific behavior in your character file:By default,
roles, channels, moderation, and presence actions are disabled for safety. Enable them explicitly if needed.Features
Message Management
Your agent can send, edit, and delete messages:Reactions
Add reactions to messages for engagement:Polls
Create interactive polls:Thread Management
Create and participate in threads:Custom Emojis and Stickers
Upload custom emojis and stickers to your server:Search and Information
Search messages and get information about members, roles, and channels:Bot Presence
Set your bot’s status and activity (requirespresence action enabled):
Moderation (Advanced)
Perform moderation actions (requiresmoderation action enabled and proper permissions):
Discord Writing Style
When configuring your agent’s personality for Discord, follow these best practices: Do:- Keep messages short and conversational (1-3 sentences)
- Use emojis for tone and emphasis
- Send multiple quick replies instead of walls of text
- Match the energy of the conversation
- Use bold for emphasis,
codefor technical terms
- Use markdown tables (they render poorly in Discord)
- Use
## Headersin casual chat - Write multi-paragraph essays
- Over-explain simple things
Plugin Auto-Loading
If you setDISCORD_BOT_TOKEN in your environment, the Discord plugin will automatically load. You can explicitly control this in your character’s plugins array:
Troubleshooting
Bot doesn’t respond
- Verify your
DISCORD_BOT_TOKENis correct - Check that the bot has been invited to your server
- Ensure the bot has proper permissions in the channel
- Check the bot’s role position in the server hierarchy
Permission errors
- Review the bot’s permissions in Server Settings > Roles
- Check channel-specific permission overrides
- Ensure the bot’s role is high enough for the actions it needs to perform
Message not sending
- Verify the channel ID is correct
- Check that the bot can view and send messages in that channel
- Ensure your message content isn’t empty
- Check for rate limiting in the console logs
Best Practices
- Start with minimal permissions - Only enable the actions your agent needs
- Test in a private server first - Create a test server before deploying to production
- Monitor rate limits - Discord has strict rate limiting; avoid spamming
- Handle errors gracefully - Implement proper error handling for failed actions
- Respect user privacy - Don’t log sensitive user data or messages
- Use threads for long conversations - Keep channels organized