OpenClaw LogoOpenClaw with ArmorIQ
Configuration

Discord Setup

Configure Discord bot with MESSAGE CONTENT INTENT for OpenClaw

Discord Bot Setup

Set up a Discord bot to interact with OpenClaw via Discord.

Discord uses the official Discord Bot API - create a bot application and get a bot token.


Prerequisites

  • A Discord account
  • Ability to create Discord applications
  • A Discord server (guild) for testing

Create Discord Bot Application

  1. Go to Discord Developer Portal: https://discord.com/developers/applications

  2. Create New Application:

    • Click "New Application"
    • Name: OpenClaw Bot (or your preferred name)
    • Click "Create"
  3. Create Bot User:

    • Go to Bot section (left sidebar)
    • Click "Add Bot" → "Yes, do it!"
    • Copy the Bot Token (save it securely)

Enable Required Intents

MESSAGE CONTENT INTENT is required! Without it, the bot cannot read message content and won't respond to any messages.

  1. Stay in Bot section
  2. Scroll to "Privileged Gateway Intents"
  3. Enable MESSAGE CONTENT INTENT (required!)
  4. Enable SERVER MEMBERS INTENT (recommended)
  5. Click "Save Changes"

Generate Bot Invite URL

  1. Go to OAuth2URL Generator
  2. Select Scopes:
    • bot
    • applications.commands
  3. Select Bot Permissions:
    • View Channels
    • Send Messages
    • Read Message History
    • Embed Links
    • Attach Files
    • Add Reactions
  4. Copy the generated URL

Invite Bot to Server

  1. Open the generated URL in your browser
  2. Select your test server
  3. Click "Authorize"
  4. Complete the captcha if prompted

Get Discord IDs

Discord uses numeric IDs for servers, channels, and users.

Enable Developer Mode

  1. Discord → User Settings → Advanced
  2. Enable Developer Mode

Copy IDs (right-click and select "Copy ID"):

  • Server ID: Right-click server name → Copy Server ID
  • Channel ID: Right-click channel (e.g., #general) → Copy Channel ID
  • Your User ID: Right-click your username → Copy User ID

Add Discord Configuration

Set environment variable:

~/.openclaw/.env
# Discord Bot Token
DISCORD_BOT_TOKEN=YOUR_BOT_TOKEN_HERE

Update configuration file ~/.openclaw/openclaw.json:

{
  "channels": {
    "discord": {
      "enabled": true,
      "dm": {
        "enabled": true,
        "policy": "allowlist",
        "allowFrom": ["123456789012345678"]
      },
      "groupPolicy": "allowlist",
      "guilds": {
        "987654321098765432": {
          "requireMention": false,
          "users": ["123456789012345678"],
          "channels": {
            "111222333444555666": {
              "allow": true,
              "requireMention": false
            }
          }
        }
      }
    }
  },
  "plugins": {
    "entries": {
      "discord": {
        "enabled": true
      }
    }
  }
}

Replace with your IDs:

  • YOUR_BOT_TOKEN_HERE - Your Discord bot token
  • 123456789012345678 - Your Discord user ID
  • 987654321098765432 - Your server (guild) ID
  • 111222333444555666 - Your channel ID

Configuration Options

FieldDescriptionDefault
dm.enabledEnable direct message supporttrue
dm.policyAccess control: allowlist, pairing, open, disabledpairing
dm.allowFromDiscord user IDs allowed to DM[]
groupPolicyServer channel policy: allowlist, open, disabledallowlist
guilds.<id>.requireMentionRequire @mention to respond in servertrue
guilds.<id>.usersUser IDs allowed in this server[]
guilds.<id>.channels.<id>.allowAllow bot in this channelfalse
guilds.<id>.channels.<id>.requireMentionRequire mention in this channeltrue

Mention vs No-Mention Mode

Bot only responds when @mentioned:

@YourBot hello
  • Prevents bot from responding to every message
  • Better for multi-user servers
  • Recommended for shared channels

With requireMention: false (Testing Only)

Bot responds to every message in allowed channels.

  • Can be noisy in active channels
  • Good for private testing channels

Verify Setup

Start Gateway

cd /path/to/aiq-openclaw
export DISCORD_BOT_TOKEN=YOUR_TOKEN
node scripts/run-node.mjs gateway

Expected Log Output

[discord] [default] starting provider (@YourBot)
[discord] logged in to discord as 1234567890123456789

Check Status

pnpm openclaw channels status --probe

Expected output:

Discord default: enabled, configured, running, works

Test Discord Bot

Test in DM

  1. Find bot in server member list
  2. Click bot → "Message"
  3. Send: Hello ArmorIQ!
  4. Bot should respond (if your user ID is in allowlist)

Test in Server Channel

  1. Go to configured channel
  2. If requireMention: false, send: hello
  3. If requireMention: true, send: @YourBot hello
  4. Bot should respond

Troubleshooting

Bot doesn't respond

Check:

  • MESSAGE CONTENT INTENT is enabled (required!)
  • Bot token is correct (starts with MTQ... or similar)
  • Bot was invited to server with correct permissions
  • User/channel IDs are in configuration
  • If requireMention: true - you must @mention the bot
  • Look for "logged in to discord" in logs

Solution:

# Check logs
tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | grep discord

# Verify bot token
echo $DISCORD_BOT_TOKEN

Missing MESSAGE CONTENT INTENT

Error: Bot receives messages but content is empty

Fix:

  1. Go to Discord Developer Portal
  2. Select your application → Bot
  3. Enable MESSAGE CONTENT INTENT
  4. Click "Save Changes"
  5. Restart gateway

Bot offline in server

Check:

  • Bot token is valid
  • Gateway is running
  • No errors in logs about Discord connection

Solution:

# Regenerate bot token if needed
# Discord Developer Portal → Bot → Reset Token

Permission errors

Error: Missing Access or Missing Permissions

Fix:

  1. Re-invite bot with correct permissions
  2. Check bot role has required permissions in server settings
  3. Verify channel permissions allow bot to read/send messages

Security Best Practices

Use Allowlist Policy

SAFE - Only specific users in allowed channels:

{
  "channels": {
    "discord": {
      "dm": {
        "policy": "allowlist",
        "allowFrom": ["123456789012345678"]
      },
      "groupPolicy": "allowlist",
      "guilds": {
        "987654321098765432": {
          "requireMention": true,
          "users": ["123456789012345678"]
        }
      }
    }
  }
}

DANGEROUS - Anyone on server can interact:

{
  "channels": {
    "discord": {
      "dm": { "policy": "open" },
      "groupPolicy": "open"  // NEVER DO THIS!
    }
  }
}

Require Mentions in Shared Channels

Set requireMention: true in shared channels to prevent the bot from responding to every message.

Token Storage

Store tokens securely in environment:

~/.openclaw/.env

Never commit tokens to version control!


Rate Limits

Discord has rate limits. If you exceed them:

  • Wait before retrying
  • Implement backoff strategies
  • Monitor logs for rate limit warnings

OpenClaw handles basic rate limiting automatically.


Next Steps

Discord configured!

Configure additional channels:

On this page