Use this path first
This guide documents the single-server Discord setup that produced the cleanest result for OpenClaw: one private Discord server, one bot application, one OpenClaw host, 1Password secret references for the bot token, and LiteLLM in front of the model layer. It keeps secrets out of local config files, keeps the bot out of public community servers, and starts with one stable default agent for the whole server.
If you are starting fresh, use this path before adding more bots, more servers, or per-channel routing.
What you need
- One Discord user account. You do not need a second human Discord account.
- One private Discord server dedicated to this OpenClaw bot.
- One OpenClaw host with a working gateway.
- One 1Password vault that supports secret references.
- One LiteLLM endpoint that fronts the model you want Discord to use.
Step 1: Create a private Discord server
- Open Discord and click the
+button in the server list. - Select
Create My Own. - Choose
For me and my friends. - Name the server something private and specific to the bot.
- Do not invite anyone else yet.
Normal text channels inside the private server are fine. They do not need to be private channels if the server itself only contains you and the bot.
Step 2: Create the Discord bot application
- Open the Discord Developer Portal at
https://discord.com/developers/applications. - Click
New Applicationand give it a clear name. - Open the new application and go to
Bot. - Click
Add Bot. - Enable these privileged intents:
Message Content IntentServer Members Intent
- Reset the token and copy it somewhere secure for the next step.
Step 3: Invite the bot to your private server
- In the same application, go to
OAuth2thenURL Generator. - Enable these scopes:
botapplications.commands
- Enable these bot permissions:
View ChannelsSend MessagesRead Message HistoryEmbed LinksAttach FilesAdd Reactions
- Open the generated URL and authorize the bot into the private server you created in Step 1.
Start with the minimum permissions above. Leave channel-management or configuration-writing permissions off until normal chat behavior is stable.
Step 4: Turn on Discord Developer Mode and collect the IDs you need
- In Discord, open
SettingsthenAdvanced. - Turn on
Developer Mode. - Right-click your Discord user and copy your user ID.
- Right-click the private server icon and copy the server ID.
- If you want to pin a specific channel to a specific agent later, right-click that channel and copy its channel ID too.
Step 5: Store the bot token in 1Password
The cleanest pattern is a dedicated 1Password item just for the bot token.
- Create a new item in your 1Password vault, for example
openclaw-discord-bot-token. - Put the Discord bot token in the
passwordfield. - If you want, store your Discord user ID and server ID in named text fields on a separate item. They are not sensitive, but keeping them together makes later edits easier.
Do not paste the token directly into .env files or your OpenClaw config.
Step 6: Add the secret references to the OpenClaw runtime environment
Add the Discord bot token and LiteLLM key as 1Password secret references in the runtime environment file your gateway loads at startup.
DISCORD_BOT_TOKEN=op://HomeLab/openclaw-discord-bot-token/password
LITELLM_API_KEY=op://HomeLab/litellm-openclaw/password
If your environment already has OPENCLAW_GATEWAY_TOKEN set, leave that in place. This guide only adds the Discord-specific lines.
Step 7: Configure OpenClaw for one Discord server and one default agent
The key behavior that worked best was simple routing: one allowed Discord server, one allowed Discord user, pairing enabled for DMs, configuration writes disabled, and one stable default agent for the whole server.
{
"auth": {
"defaultProfile": "litellm:default"
},
"agents": {
"defaults": {
"model": {
"primary": "litellm/local-model"
}
},
"hasmaster": {
"model": {
"primary": "litellm/local-model"
}
}
},
"channels": {
"discord": {
"enabled": true,
"dmPolicy": "pairing",
"groupPolicy": "allowlist",
"guilds": ["YOUR_SERVER_ID"],
"allowUsers": ["YOUR_DISCORD_USER_ID"],
"configWrites": false
}
},
"bindings": {
"defaults": {
"discord": {
"agent": "hasmaster"
}
}
}
}
Keep the Discord-facing default agent on one stable chat model through LiteLLM. For a private or low-cost setup, use a local alias such as litellm/local-model. If you want a cloud-backed business lane later, swap only the model alias, not the Discord layout.
Do not start by pointing the default Discord agent at an experimental coder model or a mixed provider path. Discord chat behaves best when the default route goes to one stable chat model.
Step 8: Restart the gateway and confirm Discord is connected
Restart the OpenClaw gateway using the wrapper or startup command your host uses. On the reference setup, the commands looked like this:
/home/parsons/1password-runtime/openclaw-op.sh gateway restart
/home/parsons/1password-runtime/openclaw-op.sh gateway health
The health output should show the gateway as healthy and Discord as connected.
Step 9: Pair the bot by DM
- Open the private server.
- Find the bot in the member list.
- Right-click the bot and choose
Message. - Send a short message such as
hi. - The bot should return a pairing code and your Discord user ID.
- Approve the code from the host shell using the command the bot shows you, for example:
openclaw pairing approve discord YOUR_CODE
Bots are not normal friend accounts. You do not add them as friends. You DM them from a server where the bot is already present.
Step 10: Validate the result
- Run gateway health again and confirm Discord is still reported as connected.
- Send the bot a DM and confirm it replies.
- Send a short message in the private server and confirm the default agent replies there too.
- Only after that should you add extra channels, channel-to-agent bindings, or channel-management permissions.
What finally mattered
- Use a dedicated private Discord server instead of adding the bot to an existing community server.
- Keep the bot token in 1Password and reference it from the runtime environment file.
- Put LiteLLM in front of the model layer and give the Discord-facing default agent one stable chat model.
- Start with one default agent for the whole server. Add per-channel routing later.
- Leave
configWritesoff at first. - Use normal text channels inside the private server unless other humans will join later.
This is the shortest path to a clean first result: one server, one bot, one default agent, one secret reference, one stable model route.