How to Connect OpenClaw to Discord: Build Your Own AI-Powered Server Bot
Turn your OpenClaw agent into a Discord bot that lives in your server, so it can chat, answer questions, and run tasks for your community.
#Why Run OpenClaw on Discord
Discord is where communities live. If you run a server — for your team, your friends, your project, your business — adding an OpenClaw agent gives everyone access to a genuinely intelligent bot that can answer questions, run tasks, search the web, write code, and remember context across conversations.
Unlike generic Discord bots that respond to slash commands with canned answers, an OpenClaw-powered bot is a full autonomous agent. It has memory. It has access to tools and skills. It can spawn sub-agents to handle complex work. And because it runs on your own hardware, you control the data, the model, and the behavior.
This guide walks you through every step: creating the bot in Discord's Developer Portal, configuring the right permissions and intents, connecting it to OpenClaw, and handling the quirks that trip people up.
#What You Need
- OpenClaw installed and running with at least one AI model configured. If you need help, start with our beginner guide.
- A Discord server where you have admin permissions. If you do not have one yet, create one (Settings → Add a Server → Create My Own → For me and my friends).
- A web browser for the Discord Developer Portal.
Want step-by-step guides for this and more?
ClawDocx Pro includes 500+ curated prompts, setup guides, SKILL.md files, and templates — everything to make your AI agent unstoppable.
See plans & pricing#Step 1: Create a Discord Application
- Go to the Discord Developer Portal.
- Click New Application in the top right.
- Give it a name — something like "OpenClaw" or your agent's name.
- Accept the terms and click Create.
You now have an application. This is the container for your bot.
#Step 2: Create the Bot and Get Your Token
- In the left sidebar, click Bot.
- Set the Username to whatever you want your bot to be called in Discord.
- Optionally upload an avatar image.
- Click Reset Token to generate your bot token.
Despite the alarming name, "Reset Token" is how you generate your first token. Nothing is being reset.
- Copy the token immediately and save it somewhere secure. You cannot view it again — only regenerate a new one.
Security warning: This token gives full control of your bot. Do not share it, do not commit it to git, do not paste it in Discord chats. Treat it like a password.
#Step 3: Enable Privileged Gateway Intents
Still on the Bot page, scroll down to Privileged Gateway Intents. Enable:
- Message Content Intent — Required. Without this, your bot cannot read message content in guild channels.
- Server Members Intent — Recommended. Required for role-based allowlists and resolving usernames to IDs.
- Presence Intent — Optional. Only needed if you want your bot to track user presence.
Click Save Changes at the bottom.
If you skip Message Content Intent, your bot will appear online but will never respond to messages. This is the number one "why isn't my bot working" issue.
#Step 4: Generate the Invite URL and Add the Bot
- In the left sidebar, click OAuth2.
- Scroll down to OAuth2 URL Generator.
- Under Scopes, check:
botapplications.commands
- A Bot Permissions section appears below. Check:
- View Channels
- Send Messages
- Read Message History
- Embed Links
- Attach Files
- Add Reactions (optional, but nice)
- Copy the generated URL at the bottom of the page.
- Paste it into your browser, select your server, and click Continue.
Your bot should now appear in your server's member list as offline. It will come online once OpenClaw connects.
#Step 5: Enable Developer Mode and Collect Your IDs
You need two IDs: your Server ID and your User ID.
- In the Discord app, go to User Settings (gear icon) → Advanced → toggle on Developer Mode.
- Right-click your server icon in the sidebar → Copy Server ID.
- Right-click your own avatar in a message → Copy User ID.
Save both IDs alongside your bot token.
#Step 6: Configure OpenClaw
Set your bot token securely through the CLI — do not send it as a chat message to your agent:
openclaw config set channels.discord.token '"YOUR_BOT_TOKEN"' --jsonopenclaw config set channels.discord.enabled true --jsonThen start or restart the gateway:
openclaw gateway restartYour bot should come online in Discord within a few seconds.
#Step 7: Pair via DM
For pairing to work, make sure you have DMs enabled for the server:
- Right-click your server icon → Privacy Settings → toggle on Direct Messages.
Now DM your bot in Discord. Send any message. It will trigger a pairing request.
In your terminal:
openclaw pairing list discordopenclaw pairing approve discord YOUR_CODEYour bot is now connected. You can message it via DM or mention it in server channels.
#Configuring Server Channels
By default, OpenClaw will respond in any channel where the bot has access and is mentioned. You can fine-tune this in your config:
{ channels: { discord: { enabled: true, token: "YOUR_BOT_TOKEN", dm: { enabled: true, policy: "allowlist", allowFrom: ["YOUR_USER_ID"], }, groupPolicy: "allowlist", guilds: { "YOUR_SERVER_ID": { slug: "my-server", requireMention: true, channels: { "general": { allow: true }, "ai-help": { allow: true }, "announcements": { allow: false }, }, }, }, }, },}#Key Settings Explained
requireMention: true— The bot only responds when @mentioned. This is what you want for most servers to avoid the bot jumping into every conversation.channels— Control which channels the bot can see and respond in. Useallow: falseto blacklist specific channels.dm.policy: "allowlist"— Only users listed inallowFromcan DM the bot directly.groupPolicy: "allowlist"— Only servers listed inguildsare allowed.
#What Your Discord Bot Can Do
Once connected, your OpenClaw agent works in Discord just like it works anywhere else:
- Answer questions with full web search, file access, and tool usage
- Spawn sub-agents for complex coding or research tasks
- Share files — it can generate and upload images, documents, code files
- Thread support — long conversations can happen in threads to keep channels clean
- Slash commands — OpenClaw registers native Discord slash commands for common actions like
/status,/cron, and/reasoning - Reactions — your agent can react to messages with emoji, making it feel like a natural participant
- Inline buttons — interactive button responses for confirmations and choices
#Running a Community Bot
If you want to run your OpenClaw bot for a community (not just yourself), keep these things in mind:
#Cost Management
Every message to your bot costs API tokens. For a busy server, this adds up. Consider:
- Using a cheaper model (Claude Haiku or GPT-4.1 Mini) for general chat
- Setting
requireMention: trueso the bot only responds when asked - Using channel allowlists to limit where the bot operates
#Rate Limits
AI model APIs have rate limits. If 50 people message your bot simultaneously, some requests will queue. OpenClaw handles this gracefully, but responses may be slower during peak usage.
#Privacy
Your OpenClaw agent has access to its tools and workspace. In a community setting, be thoughtful about what tools are enabled. You probably do not want a public-facing bot to have access to your personal email or calendar.
#Troubleshooting
Bot is online but does not respond to messages:
- Check that Message Content Intent is enabled in the Developer Portal
- Make sure the bot has "View Channel" and "Read Message History" permissions in the specific channel
- If using
requireMention, make sure you are actually @mentioning the bot
Bot responds in DM but not in server:
- Verify the server ID is in your
guildsconfig - Check
groupPolicy— if set to "allowlist", only listed guilds are allowed
"Missing Access" or "Missing Permissions" errors:
- Re-invite the bot using the OAuth2 URL with the correct permissions
- Or manually adjust the bot's role permissions in Discord server settings
Pairing does not work:
- Make sure DMs from server members are enabled in your server privacy settings
- Try removing and re-adding the bot to the server
Your agent is now live on Discord. Next steps: customize its personality, set up automated cron jobs, or explore multi-agent workflows to make it even more powerful.