Skip to main content
Discord is a popular platform for communities and gaming. nanobot can respond to direct messages and server channels with configurable mention policies.

Features

  • ✅ Bot token authentication
  • ✅ Direct message support
  • ✅ Group channel support with mention policy
  • ✅ User ID-based access control
  • ✅ Message content intent support

Setup

1

Create a Discord bot

  1. Go to https://discord.com/developers/applications
  2. Click Create New Application
  3. Navigate to Bot section → Click Add Bot
  4. Copy the bot token (you may need to click Reset Token)
2

Enable intents

In the Bot settings, enable:
  • MESSAGE CONTENT INTENT (required)
  • SERVER MEMBERS INTENT (optional — only if using member-based allow lists)
3

Get your User ID

  1. Go to Discord Settings → Advanced
  2. Enable Developer Mode
  3. Right-click your avatar or username → Copy User ID
4

Configure nanobot

Edit ~/.nanobot/config.json:
{
  "channels": {
    "discord": {
      "enabled": true,
      "token": "YOUR_BOT_TOKEN",
      "allowFrom": ["YOUR_USER_ID"],
      "groupPolicy": "mention"
    }
  }
}
5

Invite the bot to your server

  1. In Developer Portal, go to OAuth2URL Generator
  2. Under Scopes, select: bot
  3. Under Bot Permissions, select:
    • Send Messages
    • Read Message History
  4. Copy the generated URL and open it in your browser
  5. Select a server and authorize the bot
6

Start the gateway

nanobot gateway
You should see:
Discord channel connected
7

Test the connection

  1. Send a direct message to your bot in Discord
  2. Or @mention the bot in a server channel
  3. Your bot should respond!

Configuration Options

enabled
boolean
required
Enable the Discord channel
token
string
required
Bot token from Discord Developer Portal
allowFrom
array
required
List of Discord user IDs allowed to interact with the botExamples:
  • Single user: ["123456789012345678"]
  • Multiple users: ["123456789012345678", "987654321098765432"]
groupPolicy
string
default:"mention"
Controls how the bot responds in group channels (servers):
  • "mention" (default) — Only respond when @mentioned
  • "open" — Respond to all messages in channels
DMs always respond when the sender is in allowFrom, regardless of policy

Group Chat Behavior

The groupPolicy setting only affects server channels, not direct messages.

Mention mode (default)

{
  "groupPolicy": "mention"
}
Bot only responds when explicitly @mentioned in server channels.

Open mode

{
  "groupPolicy": "open"
}
Bot responds to all messages in server channels (can be noisy).

Direct messages

Always respond if sender is in allowFrom, regardless of groupPolicy.

Troubleshooting

Common issues:
  1. MESSAGE CONTENT INTENT not enabled — Go to Bot settings and enable it
  2. User ID not in allowFrom — Verify your Discord user ID
  3. Bot token invalid — Reset token in Developer Portal
  4. Missing permissions — Ensure bot has Send Messages permission
Check logs with: nanobot gateway -v
  1. Check groupPolicy setting:
    • If set to "mention", you must @mention the bot
    • Change to "open" to respond to all messages
  2. Verify bot has Read Message History permission
  3. Ensure bot role is positioned correctly (above restricted roles)
If you see “Privileged intent provided is not enabled”:
  1. Go to Discord Developer Portal → Your Application → Bot
  2. Scroll to Privileged Gateway Intents
  3. Enable MESSAGE CONTENT INTENT
  4. Save changes and restart gateway
  1. Verify the bot token is correct
  2. Check internet connectivity
  3. Restart the gateway: nanobot gateway
  4. Check Discord API status: https://discordstatus.com/

Complete Example

Full configuration with all options:
{
  "channels": {
    "discord": {
      "enabled": true,
      "token": "MTIzNDU2Nzg5MDEyMzQ1Njc4.GaBcDe.FgHiJkLmNoPqRsTuVwXyZ1234567890",
      "allowFrom": ["123456789012345678"],
      "groupPolicy": "mention"
    }
  }
}

Configuration Overview

Learn about channel configuration

Security Settings

Set up access control

Build docs developers (and LLMs) love