Ready for DMs and guild channels via the official Discord gateway.Documentation Index
Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
Pairing
Slash commands
Channel troubleshooting
Quick setup
You will need to create a new application with a bot, add the bot to your server, and pair it to OpenClaw. We recommend adding your bot to your own private server. If you don’t have one yet, create one first (choose Create My Own > For me and my friends).Create a Discord application and bot
Enable privileged intents
- Message Content Intent (required)
- Server Members Intent (recommended; required for role allowlists and name-to-ID matching)
- Presence Intent (optional; only needed for presence updates)
Copy your bot token
Generate an invite URL and add the bot to your server
botapplications.commands
- View Channels Text Permissions
- Send Messages
- Read Message History
- Embed Links
- Attach Files
- Add Reactions (optional)
Enable Developer Mode and collect your IDs
- Click User Settings (gear icon next to your avatar) → Advanced → toggle on Developer Mode
- Right-click your server icon in the sidebar → Copy Server ID
- Right-click your own avatar → Copy User ID
Allow DMs from server members
Set your bot token securely (do not send it in chat)
openclaw gateway run process.
For managed service installs, run openclaw gateway install from a shell where DISCORD_BOT_TOKEN is present, or store the variable in ~/.openclaw/.env, so the service can resolve the env SecretRef after restart.Configure OpenClaw and pair
- Ask your agent
- CLI / config
“I already set my Discord bot token in config. Please finish Discord setup with User ID<user_id>and Server ID<server_id>.”
Approve first DM pairing
- Ask your agent
- CLI
“Approve this Discord pairing code: <CODE>”
DISCORD_BOT_TOKEN is only used for the default account.
If two enabled Discord accounts resolve to the same bot token, OpenClaw starts only one gateway monitor for that token. A config-sourced token wins over the default env fallback; otherwise the first enabled account wins and the duplicate account is reported disabled.
For advanced outbound calls (message tool/channel actions), an explicit per-call token is used for that call. This applies to send and read/probe-style actions (for example read/search/fetch/thread/pins/permissions). Account policy/retry settings still come from the selected account in the active runtime snapshot.Recommended: Set up a guild workspace
Once DMs are working, you can set up your Discord server as a full workspace where each channel gets its own agent session with its own context. This is recommended for private servers where it’s just you and your bot.Add your server to the guild allowlist
- Ask your agent
- Config
“Add my Discord Server ID <server_id> to the guild allowlist”
Allow responses without @mention
message tool, so the agent can lurk by default and only post when it decides a channel reply is useful.- Ask your agent
- Config
“Allow my agent to respond on this server without having to be @mentioned”
#coding, #home, #research, or whatever fits your workflow.
Runtime model
- Gateway owns the Discord connection.
- Reply routing is deterministic: Discord inbound replies back to Discord.
- Discord guild/channel metadata is added to the model prompt as untrusted context, not as a user-visible reply prefix. If a model copies that envelope back, OpenClaw strips the copied metadata from outbound replies and from future replay context.
- By default (
session.dmScope=main), direct chats share the agent main session (agent:main:main). - Guild channels are isolated session keys (
agent:<agentId>:discord:channel:<channelId>). - Group DMs are ignored by default (
channels.discord.dm.groupEnabled=false). - Native slash commands run in isolated command sessions (
agent:<agentId>:discord:slash:<userId>), while still carryingCommandTargetSessionKeyto the routed conversation session. - Text-only cron/heartbeat announce delivery to Discord uses the final assistant-visible answer once. Media and structured component payloads remain multi-message when the agent emits multiple deliverable payloads.
Forum channels
Discord forum and media channels only accept thread posts. OpenClaw supports two ways to create them:- Send a message to the forum parent (
channel:<forumId>) to auto-create a thread. The thread title uses the first non-empty line of your message. - Use
openclaw message thread createto create a thread directly. Do not pass--message-idfor forum channels.
channel:<threadId>).
Interactive components
OpenClaw supports Discord components v2 containers for agent messages. Use the message tool with acomponents payload. Interaction results are routed back to the agent as normal inbound messages and follow the existing Discord replyToMode settings.
Supported blocks:
text,section,separator,actions,media-gallery,file- Action rows allow up to 5 buttons or a single select menu
- Select types:
string,user,role,mentionable,channel
components.reusable=true to allow buttons, selects, and forms to be used multiple times until they expire.
To restrict who can click a button, set allowedUsers on that button (Discord user IDs, tags, or *). When configured, unmatched users receive an ephemeral denial.
The /model and /models slash commands open an interactive model picker with provider, model, and compatible runtime dropdowns plus a Submit step. /models add is deprecated and now returns a deprecation message instead of registering models from chat. The picker reply is ephemeral and only the invoking user can use it.
File attachments:
fileblocks must point to an attachment reference (attachment://<filename>)- Provide the attachment via
media/path/filePath(single file); usemedia-galleryfor multiple files - Use
filenameto override the upload name when it should match the attachment reference
- Add
components.modalwith up to 5 fields - Field types:
text,checkbox,radio,select,role-select,user-select - OpenClaw adds a trigger button automatically
Access control and routing
- DM policy
- Guild policy
- Mentions and group DMs
channels.discord.dmPolicy controls DM access (legacy: channels.discord.dm.policy):pairing(default)allowlistopen(requireschannels.discord.allowFromto include"*"; legacy:channels.discord.dm.allowFrom)disabled
pairing mode).Multi-account precedence:channels.discord.accounts.default.allowFromapplies only to thedefaultaccount.- Named accounts inherit
channels.discord.allowFromwhen their ownallowFromis unset. - Named accounts do not inherit
channels.discord.accounts.default.allowFrom.
user:<id><@id>mention
Role-based agent routing
Usebindings[].match.roles to route Discord guild members to different agents by role ID. Role-based bindings accept role IDs only and are evaluated after peer or parent-peer bindings and before guild-only bindings. If a binding also sets other match fields (for example peer + guildId + roles), all configured fields must match.
Native commands and command auth
commands.nativedefaults to"auto"and is enabled for Discord.- Per-channel override:
channels.discord.commands.native. commands.native=falseexplicitly clears previously registered Discord native commands.- Native command auth uses the same Discord allowlists/policies as normal message handling.
- Commands may still be visible in Discord UI for users who are not authorized; execution still enforces OpenClaw auth and returns “not authorized”.
ephemeral: true
Feature details
Reply tags and native replies
Reply tags and native replies
Live stream preview
Live stream preview
channels.discord.streaming takes off (default) | partial | block | progress. progress maps to partial on Discord; streamMode is a legacy alias and is auto-migrated.Default stays off because Discord preview edits hit rate limits quickly when multiple bots or gateways share an account.partialedits a single preview message as tokens arrive.blockemits draft-sized chunks (usedraftChunkto tune size and breakpoints, clamped totextChunkLimit).- Media, error, and explicit-reply finals cancel pending preview edits.
streaming.preview.toolProgress(defaulttrue) controls whether tool/progress updates reuse the preview message.
block streaming is explicitly enabled, OpenClaw skips the preview stream to avoid double-streaming.History, context, and thread behavior
History, context, and thread behavior
channels.discord.historyLimitdefault20- fallback:
messages.groupChat.historyLimit 0disables
channels.discord.dmHistoryLimitchannels.discord.dms["<user_id>"].historyLimit
- Discord threads route as channel sessions and inherit parent channel config unless overridden.
- Thread sessions inherit the parent channel’s session-level
/modelselection as a model-only fallback; thread-local/modelselections still take precedence and parent transcript history is not copied unless transcript inheritance is enabled. channels.discord.thread.inheritParent(defaultfalse) opts new auto-threads into seeding from the parent transcript. Per-account overrides live underchannels.discord.accounts.<id>.thread.inheritParent.- Message-tool reactions can resolve
user:<id>DM targets. guilds.<guild>.channels.<channel>.requireMention: falseis preserved during reply-stage activation fallback.
Thread-bound sessions for subagents
Thread-bound sessions for subagents
/focus <target>bind current/new thread to a subagent/session target/unfocusremove current thread binding/agentsshow active runs and binding state/session idle <duration|off>inspect/update inactivity auto-unfocus for focused bindings/session max-age <duration|off>inspect/update hard max age for focused bindings
session.threadBindings.*sets global defaults.channels.discord.threadBindings.*overrides Discord behavior.spawnSubagentSessionsmust be true to auto-create/bind threads forsessions_spawn({ thread: true }).spawnAcpSessionsmust be true to auto-create/bind threads for ACP (/acp spawn ... --thread ...orsessions_spawn({ runtime: "acp", thread: true })).- If thread bindings are disabled for an account,
/focusand related thread binding operations are unavailable.
Persistent ACP channel bindings
Persistent ACP channel bindings
bindings[]withtype: "acp"andmatch.channel: "discord"
/acp spawn codex --bind herebinds the current channel or thread in place and keeps future messages on the same ACP session. Thread messages inherit the parent channel binding.- In a bound channel or thread,
/newand/resetreset the same ACP session in place. Temporary thread bindings can override target resolution while active. spawnAcpSessionsis only required when OpenClaw needs to create/bind a child thread via--thread auto|here.
Reaction notifications
Reaction notifications
offown(default)allallowlist(usesguilds.<id>.users)
Ack reactions
Ack reactions
ackReaction sends an acknowledgement emoji while OpenClaw is processing an inbound message.Resolution order:channels.discord.accounts.<accountId>.ackReactionchannels.discord.ackReactionmessages.ackReaction- agent identity emoji fallback (
agents.list[].identity.emoji, else ”👀”)
- Discord accepts unicode emoji or custom emoji names.
- Use
""to disable the reaction for a channel or account.
Config writes
Config writes
/config set|unset flows (when command features are enabled).Disable:Gateway proxy
Gateway proxy
channels.discord.proxy.PluralKit support
PluralKit support
- allowlists can use
pk:<memberId> - member display names are matched by name/slug only when
channels.discord.dangerouslyAllowNameMatching: true - lookups use original message ID and are time-window constrained
- if lookup fails, proxied messages are treated as bot messages and dropped unless
allowBots=true
Presence configuration
Presence configuration
- 0: Playing
- 1: Streaming (requires
activityUrl) - 2: Listening
- 3: Watching
- 4: Custom (uses the activity text as the status state; emoji is optional)
- 5: Competing
autoPresence.healthyTextautoPresence.degradedTextautoPresence.exhaustedText(supports{reason}placeholder)
Approvals in Discord
Approvals in Discord
channels.discord.execApprovals.enabledchannels.discord.execApprovals.approvers(optional; falls back tocommands.ownerAllowFromwhen possible)channels.discord.execApprovals.target(dm|channel|both, default:dm)agentFilter,sessionFilter,cleanupAfterResolve
enabled is unset or "auto" and at least one approver can be resolved, either from execApprovals.approvers or from commands.ownerAllowFrom. Discord does not infer exec approvers from channel allowFrom, legacy dm.allowFrom, or direct-message defaultTo. Set enabled: false to disable Discord as a native approval client explicitly.For sensitive owner-only group commands such as /diagnostics and /export-trajectory, OpenClaw sends approval prompts and final results privately. It tries Discord DM first when the invoking owner has a Discord owner route; if that is not available, it falls back to the first available owner route from commands.ownerAllowFrom, such as Telegram.When target is channel or both, the approval prompt is visible in the channel. Only resolved approvers can use the buttons; other users receive an ephemeral denial. Approval prompts include the command text, so only enable channel delivery in trusted channels. If the channel ID cannot be derived from the session key, OpenClaw falls back to DM delivery.Discord also renders the shared approval buttons used by other chat channels. The native Discord adapter mainly adds approver DM routing and channel fanout.
When those buttons are present, they are the primary approval UX; OpenClaw
should only include a manual /approve command when the tool result says
chat approvals are unavailable or manual approval is the only path.Gateway auth and approval resolution follow the shared Gateway client contract (plugin: IDs resolve through plugin.approval.resolve; other IDs through exec.approval.resolve). Approvals expire after 30 minutes by default.See Exec approvals.Tools and action gates
Discord message actions include messaging, channel admin, moderation, presence, and metadata actions. Core examples:- messaging:
sendMessage,readMessages,editMessage,deleteMessage,threadReply - reactions:
react,reactions,emojiList - moderation:
timeout,kick,ban - presence:
setPresence
event-create action accepts an optional image parameter (URL or local file path) to set the scheduled event cover image.
Action gates live under channels.discord.actions.*.
Default gate behavior:
| Action group | Default |
|---|---|
| reactions, messages, threads, pins, polls, search, memberInfo, roleInfo, channelInfo, channels, voiceStatus, events, stickers, emojiUploads, stickerUploads, permissions | enabled |
| roles | disabled |
| moderation | disabled |
| presence | disabled |
Components v2 UI
OpenClaw uses Discord components v2 for exec approvals and cross-context markers. Discord message actions can also acceptcomponents for custom UI (advanced; requires constructing a component payload via the discord tool), while legacy embeds remain available but are not recommended.
channels.discord.ui.components.accentColorsets the accent color used by Discord component containers (hex).- Set per account with
channels.discord.accounts.<id>.ui.components.accentColor. embedsare ignored when components v2 are present.
Voice
Discord has two distinct voice surfaces: realtime voice channels (continuous conversations) and voice message attachments (the waveform preview format). The gateway supports both.Voice channels
Setup checklist:- Enable Message Content Intent in the Discord Developer Portal.
- Enable Server Members Intent when role/user allowlists are used.
- Invite the bot with
botandapplications.commandsscopes. - Grant Connect, Speak, Send Messages, and Read Message History in the target voice channel.
- Enable native commands (
commands.nativeorchannels.discord.commands.native). - Configure
channels.discord.voice.
/vc join|leave|status to control sessions. The command uses the account default agent and follows the same allowlist and group policy rules as other Discord commands.
voice.ttsoverridesmessages.ttsfor voice playback only.voice.modeloverrides the LLM used for Discord voice channel responses only. Leave it unset to inherit the routed agent model.- STT uses
tools.media.audio;voice.modeldoes not affect transcription. - Voice transcript turns derive owner status from Discord
allowFrom(ordm.allowFrom); non-owner speakers cannot access owner-only tools (for examplegatewayandcron). - Voice is enabled by default; set
channels.discord.voice.enabled=falseto disable voice runtime and theGuildVoiceStatesgateway intent. channels.discord.intents.voiceStatescan explicitly override voice-state intent subscription. Leave it unset for the intent to followvoice.enabled.voice.daveEncryptionandvoice.decryptionFailureTolerancepass through to@discordjs/voicejoin options.@discordjs/voicedefaults aredaveEncryption=trueanddecryptionFailureTolerance=24if unset.- OpenClaw also watches receive decrypt failures and auto-recovers by leaving/rejoining the voice channel after repeated failures in a short window.
- If receive logs repeatedly show
DecryptionFailed(UnencryptedWhenPassthroughDisabled)after updating, collect a dependency report and logs. The bundled@discordjs/voiceline includes the upstream padding fix from discord.js PR #11449, which closed discord.js issue #11419.
- Discord PCM capture is converted to a WAV temp file.
tools.media.audiohandles STT, for exampleopenai/gpt-4o-mini-transcribe.- The transcript is sent through normal Discord ingress and routing.
voice.model, when set, overrides only the response LLM for this voice-channel turn.voice.ttsis merged overmessages.tts; the resulting audio is played in the joined channel.
voice.model, STT auth for tools.media.audio, and TTS auth for messages.tts/voice.tts.
Voice messages
Discord voice messages show a waveform preview and require OGG/Opus audio. OpenClaw generates the waveform automatically, but needsffmpeg and ffprobe on the gateway host to inspect and convert.
- Provide a local file path (URLs are rejected).
- Omit text content (Discord rejects text + voice message in the same payload).
- Any audio format is accepted; OpenClaw converts to OGG/Opus as needed.
Troubleshooting
Used disallowed intents or bot sees no guild messages
Used disallowed intents or bot sees no guild messages
- enable Message Content Intent
- enable Server Members Intent when you depend on user/member resolution
- restart gateway after changing intents
Guild messages blocked unexpectedly
Guild messages blocked unexpectedly
- verify
groupPolicy - verify guild allowlist under
channels.discord.guilds - if guild
channelsmap exists, only listed channels are allowed - verify
requireMentionbehavior and mention patterns
Require mention false but still blocked
Require mention false but still blocked
groupPolicy="allowlist"without matching guild/channel allowlistrequireMentionconfigured in the wrong place (must be underchannels.discord.guildsor channel entry)- sender blocked by guild/channel
usersallowlist
Long-running handlers time out or duplicate replies
Long-running handlers time out or duplicate replies
Listener DiscordMessageListener timed out after 30000ms for event MESSAGE_CREATESlow listener detected ...discord inbound worker timed out after ...
- single-account:
channels.discord.eventQueue.listenerTimeout - multi-account:
channels.discord.accounts.<accountId>.eventQueue.listenerTimeout
- single-account:
channels.discord.inboundWorker.runTimeoutMs - multi-account:
channels.discord.accounts.<accountId>.inboundWorker.runTimeoutMs - default:
1800000(30 minutes); set0to disable
eventQueue.listenerTimeout for slow listener setup and inboundWorker.runTimeoutMs
only if you want a separate safety valve for queued agent turns.Gateway metadata lookup timeout warnings
Gateway metadata lookup timeout warnings
/gateway/bot metadata before connecting. Transient failures fall back to Discord’s default gateway URL and are rate-limited in logs.Metadata timeout knobs:- single-account:
channels.discord.gatewayInfoTimeoutMs - multi-account:
channels.discord.accounts.<accountId>.gatewayInfoTimeoutMs - env fallback when config is unset:
OPENCLAW_DISCORD_GATEWAY_INFO_TIMEOUT_MS - default:
30000(30 seconds), max:120000
Permissions audit mismatches
Permissions audit mismatches
channels status --probe permission checks only work for numeric channel IDs.If you use slug keys, runtime matching can still work, but probe cannot fully verify permissions.DM and pairing issues
DM and pairing issues
- DM disabled:
channels.discord.dm.enabled=false - DM policy disabled:
channels.discord.dmPolicy="disabled"(legacy:channels.discord.dm.policy) - awaiting pairing approval in
pairingmode
Bot to bot loops
Bot to bot loops
channels.discord.allowBots=true, use strict mention and allowlist rules to avoid loop behavior.
Prefer channels.discord.allowBots="mentions" to only accept bot messages that mention the bot.Voice STT drops with DecryptionFailed(...)
Voice STT drops with DecryptionFailed(...)
- keep OpenClaw current (
openclaw update) so the Discord voice receive recovery logic is present - confirm
channels.discord.voice.daveEncryption=true(default) - start from
channels.discord.voice.decryptionFailureTolerance=24(upstream default) and tune only if needed - watch logs for:
discord voice: DAVE decrypt failures detecteddiscord voice: repeated decrypt failures; attempting rejoin
- if failures continue after automatic rejoin, collect logs and compare against the upstream DAVE receive history in discord.js #11419 and discord.js #11449
Configuration reference
Primary reference: Configuration reference - Discord.High-signal Discord fields
High-signal Discord fields
- startup/auth:
enabled,token,accounts.*,allowBots - policy:
groupPolicy,dm.*,guilds.*,guilds.*.channels.* - command:
commands.native,commands.useAccessGroups,configWrites,slashCommand.* - event queue:
eventQueue.listenerTimeout(listener budget),eventQueue.maxQueueSize,eventQueue.maxConcurrency - inbound worker:
inboundWorker.runTimeoutMs - gateway metadata:
gatewayInfoTimeoutMs - reply/history:
replyToMode,historyLimit,dmHistoryLimit,dms.*.historyLimit - delivery:
textChunkLimit,chunkMode,maxLinesPerMessage - streaming:
streaming(legacy alias:streamMode),streaming.preview.toolProgress,draftChunk,blockStreaming,blockStreamingCoalesce - media/retry:
mediaMaxMb(caps outbound Discord uploads, default100MB),retry - actions:
actions.* - presence:
activity,status,activityType,activityUrl - UI:
ui.components.accentColor - features:
threadBindings, top-levelbindings[](type: "acp"),pluralkit,execApprovals,intents,agentComponents,heartbeat,responsePrefix
Safety and operations
- Treat bot tokens as secrets (
DISCORD_BOT_TOKENpreferred in supervised environments). - Grant least-privilege Discord permissions.
- If command deploy/state is stale, restart gateway and re-check with
openclaw channels status --probe.