# Set up your first OpenClaw Discord bot

Canonical: https://cwyn.com/pages/openclaw-guide-first-discord-bot.html
Last updated: 2026-11-23T05:18:30-05:00

OpenClaw operations guide

Short answer. Create a Discord bot in the Developer Portal, connect its token on the Gateway host, and approve your first private DM. Start with a local CLI Gateway running as a managed service and a model that already replies in the dashboard.

Last updated November 23, 2026 · Published November 19, 2026

By CWYN · Reviewed November 19, 2026 against OpenClaw 2026.11.5

Start with a local CLI Gateway running as a managed service and a model that already replies in the dashboard. Use a private Discord server you control.

## 1. Create the bot and copy its token

In the [Discord Developer Portal](https://discord.com/developers/applications), choose New Application, name it, and open Bot. Under Privileged Gateway Intents, enable Message Content Intent and Server Members Intent as shown in the [Discord setup reference](https://docs.openclaw.ai/channels/discord/setup). Select Reset Token to generate the first token. Save it privately.

## 2. Invite the bot to your private server

In OAuth2 URL Generator, select `bot` and `applications.commands`. Under Bot Permissions, select View Channels, Send Messages, Read Message History, Embed Links, and Attach Files, the text setup baseline in the reference. Open the generated invite, select your test server, and authorize the bot. In the Discord app, open that server’s Privacy Settings and enable Direct Messages so the bot can send you a pairing code.

## 3. Install the plugin and connect the token

On the Gateway host, [install the official Discord plugin](https://docs.openclaw.ai/plugins/plugin-inventory). Add `DISCORD_BOT_TOKEN` to the private `~/.openclaw/.env` file using your actual token. Keep existing entries and keep the token out of chat and shell commands.

```
openclaw plugins install @openclaw/discord
```

Save this JSON5 patch as `discord.patch.json5` in your current directory. It references the token and uses [DM pairing with server-channel handling disabled](https://docs.openclaw.ai/channels/discord/access-control) for the test.

```
{
  channels: {
    discord: {
      enabled: true,
      dmPolicy: "pairing",
      groupPolicy: "disabled",
      token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
    },
  },
}
```

Run the dry run to validate the patch and token reference. If it passes, apply the patch and [restart the managed service](https://docs.openclaw.ai/cli/gateway/restart-and-supervision) so it reads the token.

```
openclaw config patch --file ./discord.patch.json5 --dry-run
openclaw config patch --file ./discord.patch.json5
openclaw gateway restart
```

## 4. Approve the DM you sent

Open a DM to the bot and send a message from your own account. Match the code in the bot’s reply to the pending request, then substitute that code for `<CODE>`. Read the [pairing reference](https://docs.openclaw.ai/channels/pairing) before approving, since the first CLI approval can establish the command owner.

```
openclaw pairing list discord
openclaw pairing approve discord <CODE>
```

## 5. Send a new message

In the same DM, send a new prompt and look for a model reply. The initial pairing message is held before it reaches the agent, so use a fresh prompt for the test.

[Get your free CWYN Score](https://cwyn.com/pages/score.html)

## Related guides

- [OpenClaw Discord bot online but not replying in a server channel](https://cwyn.com/pages/openclaw-guide-discord-bot-not-replying.html)
- [Set up your first OpenClaw Telegram bot](https://cwyn.com/pages/openclaw-guide-first-telegram-bot.html)
- [Set up your first OpenClaw IRC bot](https://cwyn.com/pages/openclaw-guide-first-irc-bot.html)

## Next steps

- [All 135 OpenClaw guides](https://cwyn.com/guides/openclaw/)
- [OpenClaw setup walkthrough](https://cwyn.com/setup/openclaw/)
- [CWYN Score](https://cwyn.com/pages/score.html)
- [OpenClaw Complete Setup Pack ($14.95)](https://cwyn.com/pages/pack-openclaw-complete-setup-pack.html)

### Keep the setup behind the first Discord reply

Use the Gateway checklist and editable workspace files in the [OpenClaw Complete Setup Pack ($14.95)](https://cwyn.com/pages/pack-openclaw-complete-setup-pack.html), an optional paid kit, to document your private Discord test.
Kit details as of Nov 22, 2026

OpenClaw Complete Setup Pack $14.95

Start an OpenClaw workspace with editable instructions, local Gateway and tool presets, and checklists for pairing, memory, costs and rollback.
