OpenClaw Discord Channel
Connect OpenClaw to Discord using the discord.js Bot Gateway API. Create a Discord bot in the Developer Portal, enable the required intents, invite the bot to your server, and your AI assistant is live on Discord. Supports direct messages, guild channel conversations, reactions, threads, slash commands, and rich media. One of the easiest channels to set up.
Discord Supported Features
Text Messages
Supported
Media & Files
Supported
Reactions
Supported
Threads
Supported
Voice Messages
Not Supported
Group Chat
Supported
Discord Prerequisites
- A Discord account with access to the Discord Developer Portal
- A Bot Token from Discord Developer Portal (Applications → New Application → Bot)
- Message Content Intent enabled in Privileged Gateway Intents
- OpenClaw Gateway running and configured
Discord Quick Setup
Create Discord bot and enable intents
Go to the Discord Developer Portal (discord.com/developers), create a New Application, add a Bot user, and copy the Bot Token. Under Privileged Gateway Intents, enable 'Message Content Intent' (required) and 'Server Members Intent' (recommended for member lookups).
Add Discord channel config
Add the Discord channel configuration to ~/.openclaw/openclaw.json. Set the token (or use DISCORD_BOT_TOKEN environment variable) and configure dm.policy to control who can DM the bot.
Invite bot to server and test
In the Developer Portal, go to OAuth2 → URL Generator. Select scopes 'bot' and 'applications.commands'. Choose permissions: View Channels, Send Messages, Read Message History, Embed Links, Attach Files, Add Reactions. Open the generated URL to invite the bot to your server. Send '@BotName hello' to test.
Discord Configuration Example
{
"channels": {
"discord": {
"enabled": true,
"token": "YOUR_DISCORD_BOT_TOKEN",
"dm": {
"policy": "pairing"
}
}
}
}Discord Deep Dive
Architecture Overview
Creating Your Bot
DM Policies
{
"channels": {
"discord": {
"dm": {
"policy": "pairing",
"allowFrom": ["123456789012345678"]
}
}
}
}Guild Channel Configuration
{
"channels": {
"discord": {
"groupPolicy": "open",
"guilds": {
"YOUR_GUILD_ID": {
"slug": "my-server",
"requireMention": true,
"channels": {
"CHANNEL_ID": {
"allow": true,
"requireMention": false,
"systemPrompt": "You are a helpful assistant in this channel."
}
}
}
}
}
}
}Reactions & Acknowledgments
{
"channels": {
"discord": {
"messages": {
"ackReaction": "👀",
"removeAckAfterReply": true
},
"guilds": {
"GUILD_ID": {
"reactionNotifications": "own"
}
}
}
}
}Message Formatting & Chunking
{
"channels": {
"discord": {
"textChunkLimit": 2000,
"chunkMode": "newline",
"historyLimit": 20
}
}
}Slash Commands & Tool Actions
Media & File Handling
PluralKit Integration
{
"channels": {
"discord": {
"pluralkit": {
"enabled": true,
"token": "pk_live_..."
}
}
}
}Exec Approvals (Button UI)
{
"channels": {
"discord": {
"execApprovals": {
"enabled": true,
"approvers": ["USER_ID_1", "USER_ID_2"],
"agentFilter": [],
"sessionFilter": []
}
}
}
}Action Gates
Allowlist Resolution & Matching
Discord Configuration Reference
| Key | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enable or disable the Discord channel |
| token | string | "" | Discord Bot Token. Can also use DISCORD_BOT_TOKEN env var |
| dm.policy | string | "pairing" | Controls who can DM the bot. Options: pairing, allowlist, open, disabled |
| dm.allowFrom | string[] | [] | Discord user IDs allowed to DM the bot (when dm.policy is allowlist) |
| groupPolicy | string | "allowlist" | Guild channel handling policy. Options: open, disabled, allowlist |
| guilds | object | {} | Per-guild configuration keyed by guild ID. Includes slug, users, channels, requireMention, etc. |
| requireMention | boolean | true | Whether the bot requires @mention to respond in guild channels |
| messages.ackReaction | string | "" | Emoji to react with as message acknowledgment while processing |
| messages.removeAckAfterReply | boolean | false | Remove the acknowledgment reaction after the AI responds |
| textChunkLimit | number | 2000 | Maximum characters per message chunk (Discord limit is 2000) |
| chunkMode | string | "length" | How to split long responses. Options: length (hard character limit), newline (paragraph boundaries) |
| historyLimit | number | 20 | Number of recent guild messages to include as AI context |
| mediaMaxMb | number | 8 | Maximum media file size in megabytes for uploads |
| replyToMode | string | "off" | Reply threading mode. Options: off, first (thread first chunk only), all (thread every chunk) |
| configWrites | boolean | true | Allow Discord-initiated config updates via /config set|unset commands |
| allowBots | boolean | false | Whether to process messages from other bots. Use with caution to avoid loops |
| retry.attempts | number | 3 | Number of retry attempts for failed Discord API calls |
| retry.minDelayMs | number | 500 | Minimum delay in milliseconds between retry attempts |
| retry.maxDelayMs | number | 30000 | Maximum delay in milliseconds between retry attempts |
| retry.jitter | number | 0.1 | Jitter factor applied to retry delays for randomization |
| dm.enabled | boolean | true | Whether to accept direct messages |
| dm.groupEnabled | boolean | false | Enable group DM handling |
| dm.groupChannels | string[] | [] | Group DM channel allowlist |
| dmHistoryLimit | number | - | Per-user DM history limit override |
| maxLinesPerMessage | number | 17 | Soft line count limit per message chunk |
| commands.native | string | boolean | "auto" | Native slash command registration. Options: auto (enabled for Discord), true, false |
| commands.text | object | {} | Text command configuration requiring standalone /... messages |
| commands.useAccessGroups | boolean | false | Whether to enforce access-group checks for commands |
| actions.* | boolean | varies | Tool action gates. Most enabled by default; roles, moderation, and presence are disabled by default |
| pluralkit.enabled | boolean | false | Enable PluralKit proxy message resolution |
Enable or disable the Discord channel
Discord Bot Token. Can also use DISCORD_BOT_TOKEN env var
Controls who can DM the bot. Options: pairing, allowlist, open, disabled
Discord user IDs allowed to DM the bot (when dm.policy is allowlist)
Guild channel handling policy. Options: open, disabled, allowlist
Per-guild configuration keyed by guild ID. Includes slug, users, channels, requireMention, etc.
Whether the bot requires @mention to respond in guild channels
Emoji to react with as message acknowledgment while processing
Remove the acknowledgment reaction after the AI responds
Maximum characters per message chunk (Discord limit is 2000)
How to split long responses. Options: length (hard character limit), newline (paragraph boundaries)
Number of recent guild messages to include as AI context
Maximum media file size in megabytes for uploads
Reply threading mode. Options: off, first (thread first chunk only), all (thread every chunk)
Allow Discord-initiated config updates via /config set|unset commands
Whether to process messages from other bots. Use with caution to avoid loops
Number of retry attempts for failed Discord API calls
Minimum delay in milliseconds between retry attempts
Maximum delay in milliseconds between retry attempts
Jitter factor applied to retry delays for randomization
Whether to accept direct messages
Enable group DM handling
Group DM channel allowlist
Per-user DM history limit override
Soft line count limit per message chunk
Native slash command registration. Options: auto (enabled for Discord), true, false
Text command configuration requiring standalone /... messages
Whether to enforce access-group checks for commands
Tool action gates. Most enabled by default; roles, moderation, and presence are disabled by default
Enable PluralKit proxy message resolution
Discord Frequently Asked Questions
Discord Troubleshooting
Message Content Intent is not enabled, the bot lacks channel permissions, or mention requirements are misconfigured.
DM handling may be disabled in config, or the pairing approval is pending.
The 'applications.commands' scope was not included in the bot's OAuth2 invite URL.
Discord API rate limits have been hit, or the gateway connection is in a bad state.
groupPolicy defaults to 'allowlist', so the bot only responds in explicitly configured guilds/channels.
execApprovals is not enabled, or the user's Discord ID is not listed in the approvers array.