From 9935384abc5a79e066da3300fcc0405ddebcede9 Mon Sep 17 00:00:00 2001 From: Per Magnus Petersen Date: Thu, 2 Apr 2026 13:56:35 +0200 Subject: [PATCH] ClaudeBot discord --- claudebot.txt | 8 +++ multi-machine-discord-channel-setup.md | 95 ++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 claudebot.txt create mode 100644 multi-machine-discord-channel-setup.md diff --git a/claudebot.txt b/claudebot.txt new file mode 100644 index 0000000..c668603 --- /dev/null +++ b/claudebot.txt @@ -0,0 +1,8 @@ +claude --channels plugin:discord@claude-plugins-official + +claude --resume Omarchy --channels plugin:discord@claude-plugins-official +claude --resume Btc --channels plugin:discord@claude-plugins-official + +1488486658549481483 Btc +1488486570938994928 Omarchy + diff --git a/multi-machine-discord-channel-setup.md b/multi-machine-discord-channel-setup.md new file mode 100644 index 0000000..830e4d6 --- /dev/null +++ b/multi-machine-discord-channel-setup.md @@ -0,0 +1,95 @@ +# Multi-Machine Discord Channel Setup + +## Context + +You have one Discord bot and multiple machines, each running Claude Code with the Discord plugin. You want messages sent to different Discord text channels to route to different machines — e.g., `#desktop` reaches your desktop, `#laptop` reaches your laptop. + +This works because the Discord plugin's `gate()` function checks guild channel opt-in per `access.json`. Each machine connects with the same bot token, and Discord delivers all messages to all instances — but each instance only acts on messages from its opted-in channel(s), silently dropping the rest. + +## Prerequisites + +- A Discord server where the bot is installed +- One text channel per machine (e.g., `#desktop`, `#laptop`, `#server`) +- Channel IDs for each (Developer Mode → right-click channel → Copy Channel ID) + +## Steps + +### 1. Create Discord channels + +In your Discord server, create one text channel per machine. Name them however you like (machine name, location, etc.). + +### 2. Copy bot token to each machine + +On each machine: +``` +mkdir -p ~/.claude/channels/discord +``` +Write `~/.claude/channels/discord/.env`: +``` +DISCORD_BOT_TOKEN=MTQ4ODQ2... (same token on all machines) +``` +``` +chmod 600 ~/.claude/channels/discord/.env +``` + +The token is already saved on this machine. For others, copy the token value over (e.g., via NFS, ssh, or manually). + +### 3. Configure each machine's access.json + +On **each machine**, set up `~/.claude/channels/discord/access.json` with only that machine's channel opted in. + +Example for machine "desktop" (channel ID `111111111111111111`): +```json +{ + "dmPolicy": "allowlist", + "allowFrom": ["YOUR_USER_SNOWFLAKE"], + "groups": { + "111111111111111111": { + "requireMention": false, + "allowFrom": [] + } + } +} +``` + +Example for machine "laptop" (channel ID `222222222222222222`): +```json +{ + "dmPolicy": "disabled", + "allowFrom": ["YOUR_USER_SNOWFLAKE"], + "groups": { + "222222222222222222": { + "requireMention": false, + "allowFrom": [] + } + } +} +``` + +Key decisions: +- **DMs**: Enable on one machine only (`"dmPolicy": "allowlist"`) and disable on the rest (`"dmPolicy": "disabled"`), so DMs don't trigger all machines +- **`requireMention`**: Set to `false` if you want every message in the channel to reach Claude without @mentioning; `true` if you prefer explicit mentions +- **`allowFrom` in groups**: Leave empty to allow any server member, or restrict to your snowflake + +### 4. Start Claude Code with the Discord channel on each machine + +``` +claude --channels plugin:discord@claude-plugins-official +``` + +All machines connect simultaneously. Each only processes messages from its own channel. + +## DM handling + +Since all instances receive DMs, only one machine should have DMs enabled. Set `"dmPolicy": "disabled"` on all others. Pick whichever machine you consider your primary for DM-based conversations. + +## Shared access.json via NFS (optional) + +If you want allowlists to stay in sync without manual copying, you could put the `.env` on NFS and use per-machine `access.json` files. However, since each machine needs different `groups`, the `access.json` must be per-machine. The `.env` (same token) can be shared. + +## Verification + +1. Start Claude with `--channels plugin:discord@claude-plugins-official` on two machines +2. Send a message in machine A's channel → only machine A receives it +3. Send a message in machine B's channel → only machine B receives it +4. Send a DM → only the machine with DMs enabled receives it