Connect Discord Bot

Set up a Discord bot with Clawdbot for AI-powered conversations in your server. Complete step-by-step guide.

Easy ⏱️ 10 min

Overview

Connect Clawdbot to Discord and bring AI-powered conversations to your server:

  • AI responses in channels and DMs
  • Slash commands for easy interaction
  • Multi-server support from one bot
  • Role-based permissions for access control

Prerequisites

  • Clawdbot installed on your machine
  • A Discord account
  • Admin access to a Discord server (or create your own)

Step 1: Create a Discord Application

  1. Go to the Discord Developer Portal
  2. Click “New Application”
  3. Enter a name (e.g., “My AI Assistant”) and click Create

Step 2: Create the Bot

  1. In your application, go to the “Bot” section in the left sidebar
  2. Click “Add Bot”“Yes, do it!”
  3. Under Token, click “Reset Token” and copy it

⚠️ Important: Keep your bot token secret. Never share it or commit it to version control.

Configure Bot Settings

Enable these options under Privileged Gateway Intents:

  • Message Content Intent — Required to read messages
  • Server Members Intent — Optional, for member info

Click Save Changes.


Step 3: Invite Bot to Your Server

  1. Go to “OAuth2”“URL Generator”
  2. Under Scopes, select:
    • bot
    • applications.commands
  3. Under Bot Permissions, select:
    • ✅ Send Messages
    • ✅ Read Message History
    • ✅ Use Slash Commands
    • ✅ Embed Links (optional, for rich responses)
  4. Copy the generated URL and open it in your browser
  5. Select your server and click Authorize

Step 4: Add Bot to Clawdbot

Run in your terminal:

clawdbot channels add discord

When prompted, paste your bot token.

Or use the setup wizard:

clawdbot onboard

Select Add messaging channelDiscord.


Step 5: Configure Bot Behavior

Set Allowed Channels

Restrict the bot to specific channels:

clawdbot config set discord.allowedChannels "123456789012345678,987654321098765432"

To get a channel ID: Right-click the channel → Copy ID (enable Developer Mode in Discord settings first).

Set Trigger Mode

Choose how the bot responds:

# Respond to mentions only (default)
clawdbot config set discord.trigger mention

# Respond to all messages in allowed channels
clawdbot config set discord.trigger all

# Respond to messages starting with a prefix
clawdbot config set discord.trigger prefix
clawdbot config set discord.prefix "!ai"

Step 6: Start the Gateway

clawdbot gateway

Your Discord bot is now online! Test it by mentioning the bot or using your configured trigger.


Slash Commands

Clawdbot automatically registers these slash commands:

CommandDescription
/ask [question]Ask the AI a question
/resetReset conversation context
/helpShow available commands

To use: Type / in any channel where the bot has access.


Multi-Server Setup

Your bot can run on multiple servers simultaneously. Each server maintains its own conversation context.

Per-Server Configuration

# Set different AI personalities per server
clawdbot config set discord.servers.123456789.personality "helpful assistant"
clawdbot config set discord.servers.987654321.personality "coding expert"

Troubleshooting

Bot is Online but Not Responding

  1. Check Message Content Intent is enabled in Developer Portal
  2. Verify the bot has permission to read/send in the channel
  3. Confirm clawdbot gateway is running

”Missing Access” Error

The bot needs proper permissions:

  1. Re-invite with correct permissions using the OAuth2 URL
  2. Or manually adjust role permissions in Server Settings

Commands Not Showing

Slash commands may take up to 1 hour to register globally. For instant updates during development:

clawdbot config set discord.guildCommands true

This registers commands per-server (instant) instead of globally.


Next Steps