ChannelsDiscord

Discord

Discord is a good choice if you want your agent in a community server, a small group, or if you are already a Discord user.

Setup Overview

Create a Discord Bot in the Developer Portal, invite it to your server, and configure the channel in OpenClaw.

# channels/discord.yaml
channel: discord
enabled: true
botToken: ${DISCORD_BOT_TOKEN}
dmPolicy: approval
groupPolicy: mention
requireMention: true
allowedGuilds:
  - "123456789012345678"  # Your server ID
allowedChannels:
  - "987654321098765432"  # Specific channel IDs

Key Config Options

OptionValuesWhat It Does
dmPolicyallowlist, approval, openControls who can DM the bot
groupPolicymention, always, neverWhen to respond in server channels
requireMentiontrue / falseRequire @bot mention
allowedGuildsArray of server IDsRestrict to specific servers
allowedChannelsArray of channel IDsRestrict to specific channels
respondInThreadstrue / falseUse threads for replies

Tips and Gotchas

Gateway instability is a known issue. Discord’s WebSocket gateway can experience crashes, zombie connections (where the bot appears online but is not receiving events), and rate limiting during high traffic. If your bot stops responding but shows as online, this is likely the cause.

Implement reconnection logic. OpenClaw handles basic reconnection, but for production Discord use, monitor the connection:

# channels/discord.yaml
reconnect:
  enabled: true
  maxAttempts: 10
  backoffMs: 5000
heartbeat:
  enabled: true
  intervalMs: 30000
  timeoutMs: 10000

Restrict to specific guilds and channels. Discord bots can be invited to any server by anyone with the invite link. Use allowedGuilds and allowedChannels to ensure your bot only responds in servers and channels you control.

Bot permissions should be minimal. When generating the invite link, only select the permissions you need:

Send Messages
Read Message History
Use Slash Commands

Do not give the bot Administrator permissions. This is one of the most common and most dangerous mistakes.

Rate limits are aggressive. Discord rate-limits bots heavily. If your agent is in a busy server, it may hit rate limits and drop messages. Use respondInThreads: true and requireMention: true to reduce the volume of messages the bot needs to process.


Next Steps