From channel-setup
Interactive setup wizard for Discord & Telegram channels. Use when the user wants to set up a new channel bot, configure server channels, or manage allowed users. Triggers: "set up discord", "configure telegram", "channel setup", "connect bot", "set up channels".
How this skill is triggered — by the user, by Claude, or both
Slash command
/channel-setup:setupThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are guiding the user through setting up a Discord channel for Claude Code.
You are guiding the user through setting up a Discord channel for Claude Code. Follow these phases in order. At each step, explain what you're doing and present numbered options. Rule: Always use numbered options for user choices. Only use open-ended questions when free-text input is required (e.g., token, profile name, user IDs).
Important: All file operations use Read/Write tools directly. All API calls use Bash(curl). Never call external scripts.
Check for existing channel configurations:
ls -la ~/.claude/channels/
Scan for discord, discord-* directories. If profiles exist, list them:
"Found existing profiles: default, frontend, backend"
Check Bun is installed (required by official channel plugin):
bun --version
Detect platform for browser opening later:
uname -s
Remember: Darwin = macOS (open), Linux = (xdg-open), other = show URL only.
Ask the user about profile selection. Display the following:
Profile 選擇
Profile 是一組獨立的 bot 設定(token + 頻道 + 權限)。 每個 profile 對應一個 Discord bot,可以同時運行多個。
請選擇:
- 使用預設 profile(推薦,適合只有一個 bot) → 設定存放在
~/.claude/channels/discord/- 建立新的具名 profile(適合多個 bot 或多個用途) → 需要提供名稱,例如
frontend、team-bot→ 設定存放在~/.claude/channels/discord-<名稱>/
If existing profiles were found in step 1, also show:
3. 修改現有 profile → 列出已有的 profile 名稱讓使用者選擇
Wait for the user to reply with a number (1/2/3) or a profile name.
~/.claude/channels/discord/[a-z0-9-] allowed), use ~/.claude/channels/discord-<profile>/Check the target directory for existing config:
.env + access.json → show summary, then display:
已有設定,請選擇:
- 修改現有設定 — 保留 token,重新設定頻道與權限
- 從頭開始 — 清除所有設定,重新輸入 token
- 取消 — 不做任何變更
.env but no access.json → resume from Phase 3 (token already saved).env + access.json + tool permissions → show status, then display:
設定已完成,請選擇:
- 修改設定 — 重新設定頻道與權限
- 查看啟動指令 — 跳到 Phase 5 顯示啟動方式
- 取消 — 不做任何變更
Show the user these manual steps:
Create a Discord Bot (manual steps):
- Go to Discord Developer Portal
- Click New Application → name it → Create
- Left menu → Bot → set username → Reset Token → copy the token
- Same page below → Privileged Gateway Intents → enable Message Content Intent
Ask the user to paste their bot token. Once received:
Trim whitespace from the token, then validate:
TOKEN="<pasted_token>" curl -sS -w "\n%{http_code}" -H "Authorization: Bot $TOKEN" https://discord.com/api/v10/users/@me
Parse the response:
id, username, discriminator. Show:
"✅ Token verified (bot: username#discriminator, ID: 123456)" Save the bot ID for later use.
❌ Token 無效,請選擇:
- 重新輸入 token
- 取消設定
Retry-After header, wait, retry once.Save the token:
mkdir -p <profile_dir>
Write the .env file:
~/.claude/channels/discord/.env
DISCORD_BOT_TOKEN=<token>
~/.claude/channels/discord-frontend/.env
DISCORD_BOT_TOKEN=<token>
DISCORD_STATE_DIR=/Users/<user>/.claude/channels/discord-frontend
Then set permissions:
chmod 600 <profile_dir>/.env
Compute the permission integer:
274878008384 = VIEW_CHANNELS(1024) | SEND_MESSAGES(2048)
| SEND_MESSAGES_IN_THREADS(274877906944)
| READ_MESSAGE_HISTORY(65536) | ATTACH_FILES(32768)
| ADD_REACTIONS(64)
Build the invite URL:
https://discord.com/oauth2/authorize?client_id=<BOT_ID>&scope=bot&permissions=274878008384
Display the URL and automatically open the browser (no asking):
open "<url>"xdg-open "<url>"Also display the URL as text so the user can copy it if the browser didn't open.
Display:
Bot 邀請完成了嗎?
- 已加入 — 繼續設定
- 遇到問題 — 顯示疑難排解
If user selects 2, show common issues (permissions, OAuth2 scope) and re-display the invite URL.
TOKEN="<token>" curl -sS -H "Authorization: Bot $TOKEN" https://discord.com/api/v10/users/@me/guilds
Parse the JSON array. Display as a numbered list:
1. My Server (ID: 123456789)
2. Test Server (ID: 987654321)
偵測到唯一伺服器:ServerName,自動選取。
Display: "請輸入伺服器編號:"
TOKEN="<token>" curl -sS -H "Authorization: Bot $TOKEN" https://discord.com/api/v10/guilds/<GUILD_ID>/channels
Parse the JSON array:
position1. #general [General]
2. #dev [Development]
3. #bot-commands [Bot]
Display: "請輸入要啟用的頻道編號(多個用逗號分隔,例如 1,3):"
未選擇任何頻道,請選擇模式:
- 僅 DM 模式 — bot 只回應私訊
- 重新選擇頻道
Display:
@mention 設定(在共用頻道中建議開啟)
- 需要 @mention 才回應(推薦)
- 所有訊息都回應
Display:
DM 存取策略
- 配對模式(推薦)— 未知使用者會收到 6 碼配對碼,你在終端確認後才能對話
- 直接輸入 User ID — 進階用戶,直接指定允許的 Discord User ID
- 停用 DM — bot 只在伺服器頻道中回應
- 跳過 — 使用預設(配對模式)
If user selects 2:
Read existing access.json from the profile directory (if it exists) to preserve any
extra fields (ackReaction, replyToMode, etc.) the official plugin may have set.
Build the access config object:
{
"dmPolicy": "<chosen_policy>",
"allowFrom": ["<user_ids_if_any>"],
"groups": {
"<channel_id>": {
"requireMention": true,
"allowFrom": []
}
},
"pending": {},
"mentionPatterns": ["<@BOT_ID>"]
}
If existing access.json had extra fields, merge them into the new object (preserve ackReaction, replyToMode, textChunkLimit, chunkMode, userLabels).
Write the merged object to <profile_dir>/access.json.
Backup settings.json first:
cp ~/.claude/settings.json ~/.claude/settings.json.bak
Read ~/.claude/settings.json. If it doesn't exist, start with {}.
Check if permissions.allow array contains "mcp__plugin_discord_discord__*".
If not present:
permissions.allow array (create the array if needed)If the write produces invalid JSON, restore from backup:
cp ~/.claude/settings.json.bak ~/.claude/settings.json
Tell the user: "✅ Tool permissions added to ~/.claude/settings.json"
Display the final summary:
/plugin install discord@claude-plugins-official
If not found: /plugin marketplace add anthropics/claude-plugins-official
After install: /reload-plugins
Alternatively, the official configure command also works:
/discord:configure <TOKEN>
claude --channels plugin:discord@claude-plugins-official
DISCORD_STATE_DIR=~/.claude/channels/discord-frontend claude --channels plugin:discord@claude-plugins-official
If pairing mode:
/channel-setup:access pair <code>
/discord:access pair <code> (only works for default profile)/channel-setup:access policy allowlist --profile <name>If allowlist mode:
If disabled:
channelsEnabled is enabled by your admin
(claude.ai → Admin settings → Claude Code → Channels)reply, react, edit_message, fetch_messages, download_attachment
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub girofu/claude-channel-plugins --plugin channel-setup