The Discord channel connects NullClaw to Discord using the WebSocket gateway for real-time message delivery and the REST API for sending messages.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nullclaw/nullclaw/llms.txt
Use this file to discover all available pages before exploring further.
Features
- WebSocket gateway for real-time events
- Guild (server) and DM support
- Configurable intents
- Bot mention detection
- Allow/deny lists for user access
- Typing indicators
- Automatic message splitting at 2000 character limit
- Session resumption on disconnect
Configuration
Add Discord to yourconfig.json:
Configuration Options
Discord bot token from the Discord Developer Portal
Guild (server) ID to restrict the bot to a specific server. If
null, bot works in all servers it’s added to.Finding guild ID: Enable Developer Mode in Discord settings, then right-click your server and select “Copy ID”List of allowed Discord user IDs. Empty list means allow all users. Use
"*" for explicit allow-all.Finding user ID: Enable Developer Mode, right-click a user, select “Copy ID”Whether to respond to messages from other bots
When
true, bot only responds to messages that mention it (using @botname)Gateway intents bitmask. Default includes:
GUILDS(1 << 0)GUILD_MESSAGES(1 << 9)MESSAGE_CONTENT(1 << 15)DIRECT_MESSAGES(1 << 12)
Account identifier for multi-account setups
Setup Guide
Create a Discord Application
- Go to Discord Developer Portal
- Click “New Application”
- Give your application a name
- Navigate to the “Bot” section in the left sidebar
- Click “Add Bot” and confirm
Configure Bot Settings
- Under “Privileged Gateway Intents”, enable:
- Message Content Intent (required)
- Server Members Intent (optional)
- Copy the bot token (click “Reset Token” if needed)
- Under “OAuth2 > URL Generator”:
- Select scope:
bot - Select permissions:
Send Messages,Read Message History,View Channels
- Select scope:
- Copy the generated URL
Invite Bot to Your Server
- Paste the OAuth2 URL in your browser
- Select your server from the dropdown
- Click “Authorize”
- Complete the captcha
Get Guild and User IDs
- Enable Developer Mode in Discord:
- User Settings > Advanced > Developer Mode
- Right-click your server name → “Copy ID” (guild_id)
- Right-click your username → “Copy ID” (for allow_from)
Gateway Intents
Discord requires you to specify which events your bot wants to receive. The default intent value (37377) includes:
Required Intents
- MESSAGE_CONTENT (32768): Required to read message content. Must be enabled in the Developer Portal under “Privileged Gateway Intents”.
Common Intent Combinations
Guild messages only:Mention-Only Mode
For bots in busy servers, enable mention-only mode:@BotName.
Message Limits
Discord enforces a 2000 character limit per message. NullClaw automatically splits longer messages while respecting UTF-8 character boundaries.Session Resumption
The Discord channel implements automatic session resumption:- Maintains session ID and sequence number
- Reconnects and resumes on disconnect
- Falls back to fresh IDENTIFY if resume fails
- Stores resume gateway URL for optimal reconnection
Typing Indicators
When the agent is processing a message, the bot shows a typing indicator in the channel. This provides real-time feedback to users.Multiple Accounts
Run multiple Discord bots simultaneously:Troubleshooting
Bot Not Connecting
- Verify bot token is correct and not expired
- Check that Message Content Intent is enabled in Developer Portal
- Ensure intents value matches enabled intents
- Check logs for gateway errors:
nullclaw --log-level debug
Bot Not Responding
- Verify user ID is in
allow_from(or list is empty) - Check that bot has permission to read messages in the channel
- If
require_mentionis true, ensure you’re mentioning the bot - Check that
allow_botsis true if testing with another bot
Missing Message Content
- Enable Message Content Intent in Developer Portal:
- Go to Bot settings > Privileged Gateway Intents
- Enable “Message Content Intent”
- Ensure
MESSAGE_CONTENTbit is set in intents (32768) - Restart NullClaw after changing intents
Frequent Disconnects
- Check network stability
- Verify heartbeat interval is being respected
- Review gateway logs for disconnect reasons
- Consider rate limiting if sending many messages
Source Code
Implementation:src/channels/discord.zig