Connect NullClaw to Discord via WebSocket gateway to create an AI assistant bot that responds to mentions and direct 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.
Prerequisites
- Discord account
- Discord server (guild) with admin permissions
- Developer Portal access for bot token
Quick Setup
Create Discord Application
Go to Discord Developer Portal and create a new application.
Invite Bot
Use OAuth2 URL Generator with
bot scope and required permissions, then open the URL to invite.Configuration
Basic Setup
Edit~/.nullclaw/config.json:
config.json
Complete Configuration
config.json
Configuration Options
token (required)
Your Discord bot token from the Developer Portal:How to get bot token
How to get bot token
- Go to Discord Developer Portal
- Create or select your application
- Navigate to “Bot” section
- Click “Reset Token” or view existing token
- Copy the token (shown only once)
guild_id (optional)
Server ID where bot is active:How to find guild ID
How to find guild ID
- Enable Developer Mode in Discord (User Settings → Advanced → Developer Mode)
- Right-click your server icon
- Select “Copy Server ID”
allow_from (required)
Usernames allowed to interact with bot:- Specific Users
- Allow All
- User IDs
allow_bots
Allow other bots to trigger your bot:false(default): Ignore messages from botstrue: Allow bot-to-bot interaction (use with caution)
require_mention
Require @mention to trigger bot in channels:false: Respond to all messages (respectingallow_from)true: Only respond when bot is mentioned with@BotName
intents
Gateway intents bitmask:37377 includes:
GUILDS(1)GUILD_MESSAGES(512)MESSAGE_CONTENT(32768)DIRECT_MESSAGES(4096)
Common intent combinations
Common intent combinations
- Basic messaging:
37377(default) - DMs only:
4096 - Guild only:
33281(GUILDS + GUILD_MESSAGES + MESSAGE_CONTENT)
Bot Permissions
When generating OAuth2 invite URL, select these permissions:Send Messages
Required to respond
Read Message History
Access message context
View Channels
See channel content
Attach Files
Send images/files
68608
Multiple Discord Bots
Run multiple Discord bots for different servers:config.json
Message Handling
Automatic Message Splitting
Discord limits messages to 2000 characters. NullClaw automatically:- Splits long responses
- Sends multiple messages sequentially
- Preserves formatting
Typing Indicators
Bot sends typing indicators while processing:- Automatically triggered on message receipt
- Stops when response is sent
- Repeats every 8 seconds for long operations
Attachments
Bot can receive and send:- Images
- Text files
- Code snippets
- Other attachments
Running the Bot
Gateway Mode (Recommended)
Run all channels including Discord:Standalone Channel
Run only Discord channel:Check Status
Background Service
Security Best Practices
Use Allowlists
Use Allowlists
Always restrict access:
Disable Bot Interaction
Disable Bot Interaction
Prevent bot loops:
Encrypt Token
Encrypt Token
Enable secret encryption:
Limit Permissions
Limit Permissions
Only grant required Discord permissions (avoid Administrator).
Troubleshooting
Bot Not Connecting
Bot Not Responding
Common causes:- Username not in
allow_from - Message Content Intent not enabled
- Bot lacking channel permissions
require_mention: truebut bot not mentioned
WebSocket Disconnections
NullClaw handles:- Automatic reconnection
- Session resumption
- Heartbeat monitoring
Invalid Session
If you see “Invalid Session” errors:- Bot token may be invalidated
- Intents may have changed
- Re-copy token from Developer Portal
- Restart NullClaw
Advanced Configuration
Channel-Specific Responses
Restrict bot to specific channels using Discord permissions:- In server settings, create a role for the bot
- Deny “View Channel” in unwanted channels
- Allow “View Channel” only where bot should respond
Slash Commands
NullClaw currently supports message-based interaction. Slash command support is planned.Voice Channel Support
Voice channels are not currently supported. For voice transcription, use:- Voice message attachments
- Upload audio files
Next Steps
Telegram Setup
Configure Telegram bot
Nostr Setup
Connect via Nostr protocol