The Discord channel allows your Corvus agent to interact with users via Discord bots using the Discord Gateway WebSocket API.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dallay/corvus/llms.txt
Use this file to discover all available pages before exploring further.
Features
- Real-time WebSocket connection via Discord Gateway
- User ID-based allowlist (snowflake IDs)
- Guild (server) filtering
- Mention-only mode
- Typing indicators
- Message splitting (2000 char limit)
- Bot message filtering
- Automatic reconnection
Discord Bot Application Setup
1. Create Application
- Go to Discord Developer Portal
- Click New Application
- Enter application name (e.g., “Corvus AI”)
- Click Create
2. Create Bot User
- In your application, navigate to Bot tab
- Click Add Bot → Yes, do it!
- Reset Token and copy the bot token:
- Enable required Privileged Gateway Intents:
- ✅ Message Content Intent (required to read message content)
- ✅ Server Members Intent (optional, for member info)
- ✅ Presence Intent (optional, for status)
3. Configure Bot Permissions
- Navigate to OAuth2 → URL Generator
- Select scopes:
- ✅
bot - ✅
applications.commands(if using slash commands later)
- ✅
- Select bot permissions:
- ✅
Read Messages/View Channels - ✅
Send Messages - ✅
Read Message History
- ✅
- Copy the generated URL
4. Invite Bot to Server
- Paste the OAuth2 URL in your browser
- Select your server from the dropdown
- Click Authorize
- Complete the captcha
5. Get User and Guild IDs
Enable Developer Mode in Discord:- User Settings → Advanced → Developer Mode (toggle on)
- Right-click your username → Copy User ID
- Example:
987654321098765432
- Right-click server icon → Copy Server ID
- Example:
123456789012345678
Configuration
Add Discord configuration to~/.corvus/config.toml:
Configuration Options
| Field | Type | Required | Description |
|---|---|---|---|
bot_token | String | Yes | Bot token from Discord Developer Portal |
guild_id | String | No | Restrict bot to specific server (omit for all servers/DMs) |
allowed_users | Array | Yes | List of allowed Discord user IDs (snowflakes) |
listen_to_bots | Boolean | No | Whether to respond to other bots (default: false) |
mention_only | Boolean | No | Require bot mention to trigger response (default: false) |
Allowlist: User IDs Only
Discord uses numeric snowflake IDs for users. You must use user IDs (not usernames):- Usernames can change and are not unique
- Snowflake IDs are permanent and globally unique
Mention-Only Mode
Whenmention_only = true, users must mention the bot to trigger a response:
- Check if message contains
<@BOT_ID>or<@!BOT_ID>(mention tags) - Strip mention tags from content before processing
- Ignore messages without mentions
- Shared channels (avoid triggering on every message)
- Group chats (only respond when explicitly called)
Guild (Server) Filtering
Restrict bot to a specific Discord server:- Omit
guild_id: Bot responds in all servers and DMs - Set
guild_id: Bot only responds in that specific server (DMs still work)
Channel/Server Permissions
The bot needs these permissions in each channel:| Permission | Required | Reason |
|---|---|---|
View Channel | Yes | Read messages in channel |
Send Messages | Yes | Reply to users |
Read Message History | Yes | Access message context |
Use External Emojis | Optional | Rich responses |
Attach Files | Optional | Send attachments |
Embed Links | Optional | Rich link previews |
- Right-click channel → Edit Channel
- Navigate to Permissions tab
- Add bot role and grant required permissions
Testing and Verification
1. Start Channel Listener
2. Health Check
Verify bot authentication:3. Send Test Message
Mention-only mode enabled:Advanced Features
Typing Indicators
While processing, Discord shows “Bot is typing…” via:Message Splitting
Discord limits messages to 2000 characters. Corvus automatically splits long responses:- Prefers splitting at newlines
- Falls back to spaces
- Hard splits at 2000-char boundary if no break point
Direct Messages (DMs)
The bot responds to DMs if:- User is in
allowed_users - User shares at least one server with the bot
- User has not blocked the bot
guild_id filter does not apply to DMs.
Ignoring Bot Messages
By default,listen_to_bots = false prevents the bot from responding to other bots (including itself).
Set to true if you want the bot to process messages from other bots (e.g., webhook integrations).
Troubleshooting
Bot Not Responding
1. Check Allowlist: Ensure your user ID is in the allowlist:987654321098765432
3. Check Message Content Intent:
In Discord Developer Portal → Bot → Privileged Gateway Intents:
- ✅ Message Content Intent must be enabled
mention_only = true, you must mention the bot:
Invalid Token Error
- Go to Bot tab
- Click Reset Token
- Copy new token and update
config.toml
Missing Permissions
- Right-click channel → Edit Channel
- Permissions → Add bot role
- Enable
Send Messages,View Channel,Read Message History
Gateway Disconnect
Rate Limiting
Discord enforces rate limits:- 5 messages per 5 seconds per channel
- Typing indicator: once per 10 seconds
Security Best Practices
- Use User IDs: Always use snowflake IDs, never usernames or nicknames
- Keep Token Secret: Never commit bot token to version control
- Empty Allowlist by Default: Start with
allowed_users = []and explicitly add users - Enable Mention-Only: Use
mention_only = truein shared channels - Restrict Guild: Set
guild_idto limit bot to your server - Monitor Logs: Watch for unauthorized access attempts
- Rotate Tokens: Reset token in Discord Developer Portal if compromised
Message ID Format
Discord message IDs follow the format:discord_123456789012345678
This format:
- Is deterministic (same message = same ID)
- Prevents duplicate processing after restart
- Uses Discord’s snowflake ID for traceability
Reference
- Source:
clients/agent-runtime/src/channels/discord.rs - Discord Developer Portal: https://discord.com/developers/applications
- Discord Gateway API: https://discord.com/developers/docs/topics/gateway
- Discord API Reference: https://discord.com/developers/docs/reference
- Line range:
discord.rs:1-842