| name | add-channel-discord |
| description | Add Discord as a channel. Runs alongside WhatsApp or other channels. Supports server text channels and DMs. Triggers on "add discord", "discord setup", "discord channel".
|
Add Discord Channel
This skill installs the Discord channel plugin and registers a Discord chat.
If the plugin is already installed (check plugins/channels/discord/), skip to "Register a Chat" below.
Preflight
Before installing, verify NanoTars is set up:
[ -d node_modules ] && echo "DEPS: ok" || echo "DEPS: missing"
docker image inspect nanoclaw-agent:latest &>/dev/null && echo "IMAGE: ok" || echo "IMAGE: not built"
if grep -q "ANTHROPIC_API_KEY\|CLAUDE_CODE_OAUTH_TOKEN" .env 2>/dev/null || [ -f "$HOME/.claude/.credentials.json" ]; then echo "AUTH: ok"; else echo "AUTH: missing"; fi
If any check fails, tell the user to run /nanotars-setup first and stop.
Prerequisites
1. Create a Discord Bot
Tell the user:
I need you to create a Discord bot:
- Go to the Discord Developer Portal
- Click New Application, give it a name
- Go to Bot in the left sidebar
- Click Reset Token and copy the bot token
- Under Privileged Gateway Intents, enable:
- Message Content Intent (required to read message text)
- Server Members Intent (optional, for display names)
- Go to OAuth2 > URL Generator:
- Scopes:
bot
- Bot Permissions:
Send Messages, Read Message History, View Channels
- Copy the generated URL and open it to invite the bot to your server
Wait for the user to provide the bot token.
Note on DMs: You must share at least one server with the bot before you can DM it directly.
Install
-
Install discord.js (per-plugin dependency):
cd plugins/channels/discord && npm install && cd -
The plugin has its own package.json — dependencies are isolated from the core.
-
Check if plugin files exist:
[ -d plugins/channels/discord ] && echo "PLUGIN_EXISTS" || echo "NEED_PLUGIN"
-
If needed, copy channel plugin files into place:
mkdir -p plugins/channels/discord
cp -r ${CLAUDE_PLUGIN_ROOT}/files/* plugins/channels/discord/
-
Add bot token to .env (get from user, never echo full token):
echo "DISCORD_BOT_TOKEN=user_provided_token" >> .env
-
Rebuild and restart:
npm run build
nanotars restart 2>/dev/null
-
Verify the bot connected:
sleep 3 && grep -i 'discord.*connected' logs/nanotars.log | tail -1
Register a Chat
Use the cross-channel pairing-code flow (same primitive that backs WhatsApp + Telegram):
- From your main chat (any registered channel), type
/register-group <folder>. The host emits a 4-digit code.
- From the Discord chat you want to register, send the 4-digit code as a normal message. The host's inbound interceptor consumes the code and atomically wires the entity-model rows.
Manually finding a channel ID (only if needed for documentation / scripted setup):
- Discord User Settings > Advanced > Developer Mode → enable
- Right-click the channel/DM → Copy Channel ID
- Format as
dc:CHANNEL_ID
For the first-ever main chat (when no other channel is registered), use nanotars pair-main from the install host instead — it issues a code that the channel plugin's inbound interceptor will consume to bootstrap the main group.
Verify
- Check logs:
tail -20 logs/nanotars.log | grep -i discord
- Send a test message and confirm the agent responds
Troubleshooting
- Bot not connecting: Check
DISCORD_BOT_TOKEN in .env
- Bot online but not reading messages: Enable Message Content Intent in Discord Developer Portal > Bot > Privileged Gateway Intents
- Messages not received: Run
/list-groups from your main chat to confirm the Discord chat is registered. Don't reach into the SQLite schema directly — the entity-model migration will silently break inline SQL.
- No response in group channel: Check trigger pattern matches or set
requiresTrigger: false
- Bot can't send messages: Ensure bot has
Send Messages permission in the channel
Uninstall
Use /nanotars-remove-plugin for a guided removal — it stops the service, removes the plugin directory, cleans up channel data, and removes registered-group entries via the proper IPC primitives. Manual steps if needed:
-
nanotars stop
-
From your main chat (before stopping), run /delete-group <folder> for each Discord-wired group you want to remove. Skip this if you want the agent_group rows preserved for re-wiring to a different channel.
-
rm -rf plugins/channels/discord/
-
Remove DISCORD_BOT_TOKEN from .env
-
nanotars restart
-
Restart NanoTars — group folders and message history are preserved.