If you're searching for "how to connect Discord to OpenClaw", the real question is usually not just whether the connection is possible. It's how to make Discord usable inside an OpenClaw workflow with the right model, the right context, and the right level of control.
That's the practical framing.
OpenClaw gives you the orchestration layer: connectors, skills, tools, prompts, approvals, and the ability to run workflows where your team already works. Discord provides the domain context. The integration becomes valuable when those two pieces are connected cleanly.
Discord + OpenClaw: What Actually Breaks (And What Most Guides Skip)
The generic advice for putting an agent in Discord is three lines long: create an app, add a bot, enable "Message Content". That gets the bot online. It does not get you a working assistant, and the reason is structural rather than a matter of tuning.
Discord is not a chat-completions API with a channel attached. It is a staged event system: a persistent WebSocket (the Gateway) pushes events to your app, a separate REST API handles every read and write, and a third surface (Interactions) handles slash commands and buttons. Each of the three has its own rate limiter, its own identifier format, and its own failure mode. An agent that reasons well over a Discord channel is mostly a question of which surface each step goes through.

Three facts drive everything below, all taken from Discord's own developer documentation:
- Most events require an intent to opt in. Intents are bitwise flags ORed together in the
IDENTIFYpayload. If you don't ask for it, you don't get it. MESSAGE_CONTENTis not an event. It is a privileged intent that decides whether thecontent,embeds,attachments,componentsandpollfields of message objects are populated at all. Without it you get aMESSAGE_CREATEevent with an empty string where the message should be.- Rate limits are per-route, per-bucket, and separate from a global budget. Bots get 50 requests per second globally. Because limits are documented as "subject to change" and must not be hardcoded, the only correct behaviour is to read the response headers.
The Three Surfaces, And When An Agent Should Use Each
| Surface | Transport | What it is for | Where an agent trips |
|---|---|---|---|
| Gateway | Persistent WebSocket (wss://gateway.discord.gg/?v=10&encoding=json) |
Receiving events: new messages, reactions, thread/member updates | Needs intents; disconnects need resume vs re-identify; payloads over 4096 bytes close the socket with code 4002 |
| HTTP API | REST (https://discord.com/api/v10) |
Sending messages, reading history, editing, deleting, threads | Per-route buckets; 429 with retry_after; invalid-request budget (see below) |
| Interactions | Webhook-style | Slash commands, buttons, modals, context-menu commands | Not bound to the bot's global rate limit — the reason a slash command feels instant while a plain message send is throttled |
The design consequence is worth stating plainly: read through the Gateway (you already have the event), act through REST. An agent that re-fetches channel history with GET /channels/{id}/messages for every reply burns its HTTP budget on data it was already pushed. And an agent that tries to answer through the Gateway instead of REST will find there is no such opcode.
Intents: The Two Lines That Decide Whether It Works
The IDENTIFY payload needs a bitmask. For an assistant that reads and answers in channels, the minimum working set is:
GUILD_MESSAGES (1 << 9) = 512
MESSAGE_CONTENT (1 << 15) = 32768
total = 33280
Add GUILD_MESSAGE_REACTIONS (1 << 10) if you want the agent to react — which for a Discord assistant is not cosmetic: a reaction is the cheapest acknowledgement that does not spend a message rate-limit bucket. Add DIRECT_MESSAGES (1 << 12) only if you actually intend DMs.
Two close codes are worth memorising, because both read as "the bot is broken" when they are configuration errors:
4013— you passed invalid intents. A malformed or misspelled bitmask.4014— you passed a privileged intent that is not enabled or not approved for your app.
The 4014 case is the one that catches people. Privileged intents are GUILD_PRESENCES, GUILD_MEMBERS and MESSAGE_CONTENT. They must first be toggled on in the Developer Portal under the app's Bot → Privileged Gateway Intents section. If the app is verified — which is required once it is in 100+ guilds — the intent must also be approved after verification.
What "approved" actually means at scale
Apps with fewer than 10,000 users can enable privileged intents themselves in the Developer Portal. At more than 10,000 unique users who can see the app across all its servers, review is required to keep access: the app or team owner gets a system DM and/or an email, plus a callout in the Developer Portal, and must submit a request. A community server that grows quietly will not notice until the threshold is crossed and the intent starts coming back denied. For an internal team server this never bites. For a public support server it is a real dependency.
What you can still see without MESSAGE_CONTENT
This is the part most write-ups get wrong. Without the intent, apps receive empty values in the content fields, with documented exceptions:
- content in messages the app itself sends
- content in DMs with the app
- content in messages where the app is mentioned
- the content of the message a message context-menu command is used on
So a bot that only answers when mentioned appears to work perfectly without the intent — until someone replies in a thread without a mention, and the agent confidently answers an empty prompt. That is the single most common "why is my assistant hallucinating in Discord" bug, and it is not a model problem.
REST Rate Limits: Read The Headers, Never The Calendar
Discord's rate limiting is applied per-route and globally, independently, with the bot token as the identity. Route buckets are grouped by the X-RateLimit-Bucket header, which is the recommended identifier because similar endpoints share buckets. Per-route limits are also calculated per top-level resource — channel_id, guild_id, and webhook_id — which means hitting the limit on /channels/1234 does not block /channels/9876.
Every response carries the accounting:
| Header | Meaning |
|---|---|
X-RateLimit-Limit |
Requests allowed in the bucket |
X-RateLimit-Remaining |
Requests left |
X-RateLimit-Reset |
Epoch seconds when the bucket resets |
X-RateLimit-Reset-After |
Seconds until reset (can have decimals) |
X-RateLimit-Bucket |
Unique bucket identifier, non-inclusive of top-level resource |
X-RateLimit-Global |
Only on 429 — the limit was the global one |
X-RateLimit-Scope |
Only on 429 — user, global, or shared |
On a 429 the body carries retry_after (float seconds) and global (boolean). The correct behaviour is to wait retry_after and retry the same call — not to rotate tokens, not to fall back to a different channel, and not to retry with a fixed backoff.
The error budget nobody watches
Beyond the request limits there is an invalid-request limit: IPs making too many invalid HTTP requests are temporarily restricted. The published figure is 10,000 invalid requests per 10 minutes, where "invalid" means a response of 401, 403, or 429. Discord's docs give the avoidance rules directly:
401— send a valid token, and stop making requests after a token becomes invalid403— inspect role and channel permissions first instead of probing429— inspect the rate limit headers and don't call an exhausted bucket
One nuance in the agent's favour: 429s returned with X-RateLimit-Scope: shared are not counted against you. The pathological case for an AI agent is a loop: model takes an action, gets a 403, retries with a variation, gets another 403. Forty iterations of that against one channel is forty invalid requests — and the failure mode at the end is not a 403, it is a temporary ban that looks like an outage.

There is one more asymmetry: interaction endpoints are not bound to the bot's global rate limit. Slash commands get their own budget. For a busy server, routing the agent's reply through a slash command or a component interaction is a materially different performance profile from replying to a message event.
Configuring OpenClaw for Discord
OpenClaw consumes Discord over the same three surfaces. A working minimum configuration is a bot token, a guild ID, and the intents the workflow actually needs:
// ~/.openclaw/settings.json — Discord channel
{
channels: {
discord: {
enabled: true,
botToken: "YOUR_BOT_TOKEN", // Bot → Reset Token in the Developer Portal
guildId: "YOUR_GUILD_ID", // right-click the server → Copy Server ID
intents: ["Guilds", "GuildMessages", "MessageContent"],
// Optional: restrict where the agent may speak at all
allowedChannels: ["1122334455667788990"],
},
},
}
Three notes on that block:
MessageContentin the client config is not a substitute for enabling the intent in the Developer Portal. Both must be true. The client asking for an intent the app has not enabled produces the4014close code above.- The guild ID is not the channel ID. Pasting a channel ID into
guildIdproduces a bot that connects, receives events and never matches anything. allowedChannelsis the cheapest guardrail in Discord, because Discord's own permission model is per-channel and an agent withSend Messagesin a public channel will happily answer there.
For the permission side, the OAuth2 URL Generator needs the bot scope plus the permissions the workflow requires — View Channels, Send Messages, Read Message History, and Embed Links if the agent formats output. The bot needs a role position above any channel overwrites it is meant to bypass; a bot with the right permissions but a low role still cannot post in a channel restricted to a higher role.

OAuth2, Bot Tokens, And The Refresh Trap
There are three ways into the Discord API, and they are not interchangeable:
| Method | Identity | Refresh behaviour | Right for |
|---|---|---|---|
| Bot token | The bot | Long-lived until reset in the portal | Anything operating in servers |
| Authorization code + PKCE | The consenting user | expires_in (e.g. 604800s) plus a refresh_token |
Acting as a human across guilds |
| Implicit grant | The consenting user | No refresh token at all | Prototypes only |
Discord's own docs are blunt about the implicit grant: it returns the access token in the URL fragment, "where it can leak through browser history, logs, and Referer headers", and it does not issue a refresh token, so the user must re-authorise when it expires. For production, use authorization code with PKCE.
Refreshing is a POST /oauth2/token with grant_type=refresh_token and the refresh token, authenticating with client ID and secret. Revocation is POST /oauth2/token/revoke — and note the documented behaviour: revoking any token associated with an authorization revokes every active access and refresh token for it. There is no partial revocation. An agent that "refreshes" by revoking and re-consenting will need a human every cycle.
Five Workflows That Are Actually Worth Building
1. Channel catch-up instead of channel scrolling
"Read the last 200 messages in #launch-feedback, group them by theme, and give me the three complaints that appear more than twice with a representative quote for each."
The right shape is Gateway-collected messages cached by the agent, not a per-request GET /channels/{id}/messages?limit=100 sweep. Note the REST default page size — 100 is the maximum for message history, so a 200-message window is at least two calls, and pagination is before=<message_id>, not an offset.
2. Support triage with reaction-as-acknowledgement
"Watch the support channel. For every new message, decide whether it is a bug report, a billing question, or a feature request. React with 🐛, 💳 or 💡, and post a one-line summary in #support-digest."
The reaction is deliberate: reactions do not consume the message-send bucket, they are visible to humans immediately, and a wrong reaction is trivially removed. It also keeps the main channel uncluttered — this is the pattern that scales when 400 people are in the server.
3. Thread summarisation with an explicit boundary
"Summarise this thread. If the thread has more than 50 messages, summarise the first 20, the last 20, and list what was decided in between rather than trying to cover everything."
Threads have their own create endpoints and their own limits. The explicit instruction is not laziness — it is the guardrail against an agent silently truncating a long thread and presenting the truncation as a complete summary.
4. Moderation triage that never acts alone
"Flag any message in #general that looks like it violates the server rules. Do not delete, mute, or ban anything. Post your reasoning in the mod channel with a link to the message."
Mutes and bans are irreversible in the sense that matters — the audit log records them against the bot, and bans require Ban Members. Keep destructive moderation behind a human, and let the agent's output be a recommendation with the message ID attached.
5. Cross-tool answer in Discord
"Someone asked in #ask-eng about the outage. Pull the last three incidents from Linear and the relevant runbook section, and answer in the thread with links."
This is where the Discord channel stops being a chatbot surface and becomes a delivery surface. The agent's real work happens in the other tools; Discord is where a human is already looking.
Pitfalls Specific to Discord
4014is not a bug. A privileged intent is enabled per-app in the Developer Portal and, past 100 guilds, also approved after verification. Neither happens automatically.- The mention-only test passes without MESSAGE_CONTENT. Mentions, DMs with the app, and the app's own messages contain content regardless of the intent. Test with a plain channel message, or you will ship a bot that only fails on the queries users actually type.
- Empty
contentreads as a model failure. When the intent is missing the field is empty, not absent, and a summariser will happily produce a plausible summary of nothing. - A 403 retry loop is worse than a 403. Invalid requests are capped at 10,000 per 10 minutes per IP, and repeated 401/403/429 responses get an IP temporarily restricted. Stop after a token or permission failure; do not vary and retry.
- Never hardcode rate limits. Discord states limits are subject to change and must be read from headers. A hardcoded "5 messages per 5 seconds" is wrong on some route today and will be wrong everywhere eventually.
X-RateLimit-Bucketis the identity, not the URL. Similar endpoints share a bucket, and per-route limits are calculated per top-level resource — so a new channel does not mean a fresh quota.- Emoji routes do not follow the rules. Discord documents emoji routes as limited per-guild with inaccurate quota reporting, so expect 429s even when headers look fine.
- Payloads over 4096 bytes close the socket with
4002. Large embeds or longpresencepayloads sent over the Gateway kill the connection; content payloads belong on REST. - Resume is not reconnect. Every disconnect needs a decision:
RESUME(opcode 6) onresume_gateway_urlwith the cached sequence number, or a full re-identify. Blindly re-identifying on every blip burns the session-start budget; blindly resuming an invalid session loops. - Session starts are finite.
GET /gateway/botreturns asession_start_limitwithtotal,remaining,reset_afterandmax_concurrency. A crash-looping bot exhausts itsremainingand then cannot connect at all until reset. - Missing a heartbeat ACK means reconnect. If no
HEARTBEAT_ACK(opcode 11) arrives, close and reconnect — Discord also sends its ownHEARTBEAT(opcode 1) that must be answered immediately. - Implicit grant has no refresh token. A token that worked yesterday expires and the integration needs a human to re-consent. Use authorization code with PKCE.
- Revoking one token kills the authorization.
POST /oauth2/token/revokerevokes every access and refresh token for that grant. - Thread replies need the thread channel ID, not the parent. Posting to the parent channel does not thread the reply, and
message_referencealone is not what creates the thread. - Bots can't see role-gated channels they aren't in.
403 Missing Accessis usually a channel overwrite;50001 Missing Accessis usually the missingView Channelspermission. Neither is fixed by re-inviting with more permissions if the bot's role sits below the overwritten role. - Discord's UI is not the API's model. A "category" is a channel type, a "stage" is a voice variant, and forum posts are threads on a forum-type channel. Naming drift here produces wrong tool arguments more often than any rate limit.
When Not to Build This
If what you want is "the team's assistant answers in Discord too", the build above is real work: a Gateway client that survives disconnects, a cache, an intent strategy that depends on your server size, a rate-limit-aware sender, and a permission model you will re-explain every time someone adds a channel.
Cody ships the Discord integration already connected, so channel summaries and cross-tool answers arrive without anyone owning a WebSocket lifecycle — and the same assistant answers in Slack, where most teams spend their working hours. If you are doing this comparison for a team that lives in both, see how to connect Slack to OpenClaw alongside this one. If you want the MCP-side view of Discord as a tool surface, start with the Discord MCP page and Discord with ChatGPT; if your team coordinates in Telegram instead, connecting Telegram to OpenClaw has the equivalent write-up.
What “Connect Discord to OpenClaw” Actually Means
In practice, connecting Discord to OpenClaw usually involves four layers:
- Authentication so OpenClaw can securely access Discord
- Tooling or proxy endpoints that expose the right Discord actions and data
- Skills/instructions that tell OpenClaw how to reason over Discord context
- Model selection so the assistant uses the right LLM for the job
That last piece matters more than most people expect.
Which Models Can You Use?
OpenClaw is model-flexible, so a Discord integration does not need to be tied to a single provider. Depending on your setup, teams commonly want to use:
- OpenAI models for broad reasoning, structured extraction, and tool use
- Anthropic models for writing, analysis, and long-context work
- Google models for multimodal and large-context workflows
- Other model backends if your OpenClaw environment exposes them
Model names and availability change frequently, so check your OpenClaw model catalogue rather than copying a version from a guide. The practical point is that you can connect Discord once, then choose a supported model for each workflow.
For example:
- Use Claude for nuanced summarisation or drafting
- Use OpenAI for structured extraction, tool-heavy workflows, or general-purpose copiloting
- Use Gemini when multimodal or very large context windows matter
A Good Integration Pattern for Discord
A strong Discord + OpenClaw setup usually looks like this:
- OpenClaw receives a request in chat or from an automation
- It calls the right Discord endpoint or proxy
- The selected model reasons over the returned context
- OpenClaw returns an answer, draft, classification, or action
- High-risk actions stay behind approvals or structured guardrails
That is what makes the setup operational rather than just experimental.
Step-by-Step: Connect Discord to OpenClaw
Step 1: Create a Discord Application and Bot
Go to the Discord Developer Portal, create a new application, and add a Bot user. Under the Bot settings, copy the Bot Token. You'll also need to enable the Message Content Intent — this privileged intent is required for OpenClaw to read message text. Without it, the bot can only see mentions and slash command payloads.
Step 2: Set the Required Permissions and Invite the Bot
In the OAuth2 URL Generator, select the bot scope and the permissions your bot needs: Read Messages/View Channels, Send Messages, Read Message History. Generate the invite URL and use it to add the bot to your server. Once it's in, configure your OpenClaw instance with the bot token and the Guild (server) ID it should respond in.
Step 3: Configure Gateway Intents and Test
Discord's Gateway API uses Intents to control which events your bot receives. OpenClaw needs at minimum GUILD_MESSAGES and MESSAGE_CONTENT (privileged). Set these in your application's bot settings and in your OpenClaw configuration. Test by mentioning the bot in a channel — it should respond via Claude within a few seconds.
Model-Specific Workflow Ideas
Discord + OpenAI
Use this when you want a strong general-purpose setup for extraction, classification, action planning, and tool-driven workflows around Discord.
Discord + Claude
Use this when you want better writing quality, clearer summaries, stronger nuance, and reliable long-context reasoning over Discord data.
Discord + Gemini
Use this when the workflow benefits from large context windows, multimodal inputs, or Google-native ecosystem alignment.
Common Mistakes
Most teams do not fail because the model is bad. They fail because:
- the Discord connection is too thin
- the model lacks the right live context
- prompts are vague
- no structured outputs are enforced
- permissions and approvals are skipped
- one model is forced to do every job, even when another would be a better fit
The best setup is usually one integration layer, multiple model options, and clear guardrails.
Challenges and Caveats
Message Content Intent Is Now Privileged
As of 2022, Discord requires explicit approval for bots that read message content in servers with over 100 members. For small teams this is approved automatically, but for larger communities or public bots, you need to apply for verification and the privileged intent. This can take time and isn't guaranteed for bots with broad access.
Discord Rate Limits Are Per-Route
Discord's API applies rate limits per route (endpoint + HTTP method). Sending many messages in quick succession will hit the POST /channels/{id}/messages rate limit. For bots responding to high message volume, OpenClaw needs rate limit aware queuing.
Want Discord Connected to OpenClaw Without Building the Whole Stack Yourself?
Cody gives your team a Discord AI assistant that can summarise channels, triage support or community questions, and pull context from your connected tools without making you build or maintain custom bot infrastructure.
Related OpenClaw Guides
- How to Connect Slack to OpenClaw
- How to Connect Telegram to OpenClaw
- How to Connect Notion to OpenClaw
Looking for a more workflow-first angle? See: Discord AI Automation and Discord AI Assistant.
More Discord Resources
- Cody AI Assistant for Discord — Cody's dedicated Discord integration features and benefits