🦞OpenClaw Guide
Discord

Discord Bot Setup — OpenClaw Integration Guide

Complete guide to setting up Discord as a channel for OpenClaw. Covers bot creation, permissions, authorization errors, slash commands, duplicate messages, per-channel configuration, and credential storage.

⚠️ The Problem

Users encounter various issues when setting up Discord with OpenClaw, including: 'The application did not respond' errors, 'not authorized' messages when using slash commands, 'Unknown Channel' errors when the bot tries to reply, duplicate messages being sent, model configuration not saving, and difficulty setting up per-channel system prompts or storing credentials for reuse.

🔍 Why This Happens

These issues stem from several root causes: 1. Missing Message Content Intent: Discord bots cannot read message content without this privileged intent enabled 2. OpenClaw authorization vs Discord permissions: Discord admin permissions don't authorize you in OpenClaw — you need to be on the allowlist or approved via pairing 3. Channel/Guild not allowlisted: By default, groupPolicy: "allowlist" blocks all guilds/channels not explicitly configured 4. Duplicate gateway instances: After updates, old gateway processes may run alongside new ones, causing duplicate messages 5. Bot invitation issues: Bot may lack proper scopes/permissions, or channel ID may be incorrect 6. Separate session contexts: Each Discord channel/thread is a separate session — credentials shared in one don't carry to others

The Fix

## Step 1: Create Your Discord Bot

1. Go to [Discord Developer Portal](https://discord.com/developers/applications)

2. Click New Application and name it

3. Go to Bot section → Click Add Bot

4. Copy the bot token (click Reset Token if needed)

Critical: Enable Privileged Intents:

- Scroll down to Privileged Gateway Intents

- Enable Message Content Intent ✅ (REQUIRED for reading messages)

- Enable Server Members Intent ✅ (recommended)

- Save changes

## Step 2: Generate Bot Invite URL

Go to OAuth2 → URL Generator:

- Scopes: Select bot and applications.commands

- Bot Permissions: Select at minimum:

- Send Messages

- Read Message History

- Use Slash Commands

- (Optional) Administrator for full access

- Copy the generated URL and open it to invite the bot to your server

## Step 3: Configure Discord in OpenClaw

json5
// ~/.openclaw/config.json5{  channels: {    discord: {      enabled: true,      botToken: "YOUR_DISCORD_BOT_TOKEN",      dmPolicy: "pairing",      // or "allowlist", "open"      groupPolicy: "allowlist", // guilds must be explicitly allowed      guilds: {        "YOUR_GUILD_ID": {          users: ["YOUR_USER_ID"],  // authorized users          channels: {            "YOUR_CHANNEL_ID": { allow: true }          }        }      }    }  }}

How to get IDs:

1. Enable Developer Mode: Discord Settings → App Settings → Advanced → Developer Mode

2. Right-click server → Copy Server ID (Guild ID)

3. Right-click channel → Copy Channel ID

4. Right-click yourself → Copy User ID

## Step 4: Fix 'Not Authorized' Errors

The 'not authorized' message comes from OpenClaw, not Discord. Even with Discord admin permissions, you must be authorized in OpenClaw:

For DMs (using pairing):

bash
# List pending Discord pairing requestsopenclaw pairing list discord# Approve your pairing codeopenclaw pairing approve discord <code>

For Server Channels (using allowlist):

json5
channels: {  discord: {    groupPolicy: "allowlist",    guilds: {      "123456789012345678": {  // Your Guild ID        users: ["987654321098765432"],  // Your User ID        channels: {          "111222333444555666": { allow: true }  // Channel ID        }      }    }  }}

## Step 5: Fix 'Unknown Channel' Errors

If the bot receives messages but fails to reply with Unknown Channel:

1. Verify the channel ID is correct — Right-click channel → Copy ID

2. Check bot permissions in that channel — Bot needs Send Messages permission

3. Ensure the channel exists — Private channels or deleted channels cause this

4. Try recreating the bot — Sometimes the bot-channel binding gets corrupted

bash
# Check what channels the bot can seeopenclaw logs --follow | grep -i channel

## Step 6: Fix Duplicate Messages

If you're seeing every message processed twice:

bash
# Check for duplicate gateway instancesopenclaw status --deep# Look under 'Health' → 'Discord' → 'Agents active'# Should show only ONE agent, not duplicates# Also check for old processesps aux | grep -E '(clawdbot|moltbot|openclaw).*gateway'# Kill any old instancesclawdbot gateway stop 2>/dev/nullmoltbot gateway stop 2>/dev/null# Restart OpenClaw onlyopenclaw gateway restart

After migration (Clawdbot/Moltbot → OpenClaw):

bash
# Stop ALL gateway servicessudo systemctl stop clawdbot-gateway 2>/dev/nullsudo systemctl stop moltbot-gateway 2>/dev/nullsudo systemctl disable clawdbot-gateway 2>/dev/nullsudo systemctl disable moltbot-gateway 2>/dev/null# Keep only openclaw-gatewayopenclaw gateway restart

## Step 7: Set Up Per-Channel System Prompts

Configure different prompts for different channels:

json5
channels: {  discord: {    guilds: {      "YOUR_GUILD_ID": {        channels: {          "support-channel": {            allow: true,            systemPrompt: "You are a helpful support agent. Be concise and professional."          },          "creative-channel": {            allow: true,            systemPrompt: "You are a creative writing assistant. Be imaginative and expressive."          }        }      }    }  }}

Note: Channel keys can be the channel ID (preferred) or slug (lowercase, spaces as dashes).

## Step 8: Store Credentials for Reuse

Each Discord channel/thread is a separate session. Credentials typed in chat won't carry over.

For API tokens (GitHub, etc.) — Store on the gateway host:

bash
# Add to ~/.openclaw/.envecho 'GH_TOKEN=ghp_xxxxxxxxxxxx' >> ~/.openclaw/.envecho 'GITHUB_TOKEN=ghp_xxxxxxxxxxxx' >> ~/.openclaw/.env# Restart gateway to pick up env varsopenclaw gateway restart

For model credentials — Configure in config.json5, not in chat:

json5
models: {  providers: {    anthropic: {      apiKey: "sk-ant-xxxxx"    },    openai: {      apiKey: "sk-xxxxx"    }  }}

## Step 9: Verify Everything is Working

bash
# Full status checkopenclaw status --deep# Check Discord specificallyopenclaw channels status# Should show:# - Discord: enabled, configured, running# Test the connection# Send a message in your allowed channel: @YourBot hello# Watch logs for issuesopenclaw logs --follow

## Common Error Messages and Fixes

| Error | Cause | Fix |

|-------|-------|-----|

| The application did not respond | Gateway not running or bot misconfigured | Run openclaw gateway status, check logs |

| You are not authorized | User not in OpenClaw allowlist | Add user ID to guilds.users array |

| Unknown Channel | Channel ID wrong or bot lacks permissions | Verify channel ID, check bot permissions |

| Missing Access | Bot not in server or lacks permissions | Re-invite bot with proper scopes |

| Duplicate messages | Multiple gateway instances running | Stop old instances, keep only openclaw-gateway |

🔥 Your AI should run your business, not just answer questions.

We'll show you how.$97/mo (going to $197 soon)

Join Vibe Combinator →

📋 Quick Commands

CommandDescription
openclaw pairing list discordList pending Discord DM pairing requests
openclaw pairing approve discord <code>Approve a Discord pairing request
openclaw channels statusCheck status of Discord channel connection
openclaw status --deepFull status check including agent count (detects duplicates)
openclaw gateway restartRestart gateway to apply configuration changes
openclaw logs --followWatch live logs for Discord-related errors

Related Issues

🐙 Your AI should run your business.

Weekly live builds + template vault. We'll show you how to make AI actually work.$97/mo (going to $197 soon)

Join Vibe Combinator →

Still stuck?

Join our Discord community for real-time help.

Join Discord