claude-discord-bot-to-bot
A fork of Anthropic's official Discord channel plugin for Claude Code, modified to support bot-to-bot messaging. Multiple Claude Code sessions can coordinate with each other (and with human users) in shared Discord channels via @mentions.
What's different from the official plugin?
The official Discord plugin ignores all messages from other bots (if (msg.author.bot) return). This fork changes that to:
- Ignore own messages (self-loop prevention)
- Ignore bot messages that don't @mention this bot (noise filter)
- Process bot messages that DO @mention this bot (bot-to-bot communication)
This lets you run multiple Claude Code agents — each with its own Discord bot identity — and have them talk to each other in shared Discord channels.
Prerequisites
- Bun runtime (
curl -fsSL https://bun.sh/install | bash)
- Claude Code CLI installed
- A Discord account
Setup
1. Create a Discord bot for each agent
Each Claude Code session that needs to send/receive on Discord needs its own bot. Go through these steps once per agent identity:
-
Go to the Discord Developer Portal and click New Application. Name it after the agent role (e.g., "Coder", "Reviewer", "Architect").
-
Navigate to Bot in the sidebar. Set a username. Optionally set an avatar to visually distinguish agents.
-
Under Privileged Gateway Intents, enable Message Content Intent — without this the bot receives messages with empty content.
-
Under Bot > Token, click Reset Token and copy it. You'll need this in step 3. The token is only shown once.
-
Navigate to OAuth2 > URL Generator. Select the bot scope. Under Bot Permissions, enable:
- View Channels
- Send Messages
- Send Messages in Threads
- Read Message History
- Attach Files
- Add Reactions
-
Set Integration type to Guild Install. Copy the generated URL and open it to add the bot to your server.
-
Repeat for each agent identity.
For the full Discord bot setup guide, see Anthropic's plugin docs.
2. Install the plugin
a. Clone this repo:
git clone https://github.com/dsieczko/claude-discord-bot-to-bot.git ~/claude-plugins/claude-discord-bot-to-bot
b. Register the parent directory as a plugin marketplace from inside a Claude Code session:
/plugin marketplace add ~/claude-plugins
This tells Claude Code to scan ~/claude-plugins/ for plugin directories. It auto-populates ~/.claude/settings.json under extraKnownMarketplaces.
c. Install the plugin:
/plugin install discord-b2b@claude-plugins
The plugin name discord-b2b comes from .claude-plugin/plugin.json in this repo. The marketplace name matches the directory name you registered.
If you also have the official discord plugin installed, uninstall it from a Claude Code session to avoid conflicts:
/plugin uninstall discord
3. Configure the bot token
Each agent needs its own bot token. There are two ways to set it:
Option A: Per-session environment variable (recommended for multi-agent)
Set DISCORD_BOT_TOKEN as a session environment variable when launching Claude Code. Each terminal session uses a different token, so each agent gets its own Discord identity:
# Terminal 1 — "Coder" agent
DISCORD_BOT_TOKEN=MTIz... claude --channels plugin:discord-b2b
# Terminal 2 — "Reviewer" agent
DISCORD_BOT_TOKEN=NDU2... claude --channels plugin:discord-b2b
# Terminal 3 — "Architect" agent
DISCORD_BOT_TOKEN=Nzg5... claude --channels plugin:discord-b2b
The environment variable takes precedence over the .env file, so you can run multiple identities on the same machine without conflicts.
Option B: Config file (single-agent setups)
From inside a Claude Code session:
/discord:configure MTIz...
This writes DISCORD_BOT_TOKEN=... to ~/.claude/channels/discord/.env.
4. Launch with the channel flag
Claude Code won't connect to Discord unless you pass --channels with the full plugin reference:
claude --channels plugin:discord-b2b
Or with the token inline:
DISCORD_BOT_TOKEN=MTIz... claude --channels plugin:discord-b2b
The plugin name discord-b2b comes from .claude-plugin/plugin.json. The --channels flag uses the plugin name — no marketplace qualifier needed.
5. Pair and allow
The first time a user or bot DMs your agent's bot, it gets a pairing code. Approve it from the Claude Code session:
/discord:access pair <code>
For guild channels (shared server channels), opt in by channel ID:
/discord:access group add <channel-id>
Once everyone is added, lock down the policy:
/discord:access policy allowlist
Multi-agent setup