Guides3 min read

Connect OpenClaw to Discord: Full Tutorial

Step-by-step guide to integrating OpenClaw (formerly Clawd.bot) with Discord. Create a bot, configure permissions, and get your AI chatbot running in your server.

Published: 27/01/2025 · Updated: 29/01/2026

Introduction

This guide walks you through connecting OpenClaw to Discord, from creating a bot application to inviting it to your server.

Prerequisites

Step 1: Create a Discord Application

  1. Go to the Discord Developer Portal
  2. Click New Application
  3. Name your application (e.g., "My AI Bot")
  4. Click Create

Step 2: Create a Bot User

  1. In your application, go to the Bot section
  2. Click Add Bot
  3. Confirm by clicking Yes, do it!

Configure Bot Settings

Under Privileged Gateway Intents, enable:

  • Presence Intent - Optional, for status updates
  • Server Members Intent - Required for member info
  • Message Content Intent - Required to read messages

Step 3: Get Your Bot Token

  1. In the Bot section, click Reset Token
  2. Copy the token immediately (you can only see it once)
  3. Keep this token secret - never share it publicly

Step 4: Configure OpenClaw

SSH into your VPS and update your environment file:

cd /opt/openclaw
nano .env

Add or update:

DISCORD_TOKEN=your-bot-token-here
DISCORD_PREFIX=!

Step 5: Invite Bot to Your Server

  1. Go to OAuth2 > URL Generator

  2. Select scopes:

    • bot
    • applications.commands
  3. Select bot permissions:

    • Read Messages/View Channels
    • Send Messages
    • Embed Links
    • Attach Files
    • Read Message History
    • Use Slash Commands
  4. Copy the generated URL and open it in your browser

  5. Select your server and click Authorize

Step 6: Start the Bot

pm2 restart openclaw

Verify it's online:

pm2 logs openclaw --lines 20

You should see a message like "Bot logged in as YourBot#1234".

Step 7: Test the Bot

In your Discord server, try:

!help

Or mention the bot directly:

@YourBot Hello, how are you?

Configuring Channels

Restrict to Specific Channels

Add to your .env:

DISCORD_ALLOWED_CHANNELS=123456789,987654321

Set Up a Dedicated Bot Channel

  1. Create a new channel (e.g., #ai-chat)
  2. Set permissions so only the bot can send messages
  3. Add the channel ID to allowed channels

Per-Channel Settings

Create different behaviors for different channels:

# Support channel - formal responses
DISCORD_CHANNEL_987654321_PROMPT=You are a helpful support assistant.

# General chat - casual responses
DISCORD_CHANNEL_123456789_PROMPT=You are a friendly chat companion.

Rate Limiting

Prevent spam and API overuse:

DISCORD_RATE_LIMIT=5
DISCORD_RATE_LIMIT_WINDOW=60

Troubleshooting

Bot appears offline

  • Check token is correct: grep DISCORD_TOKEN .env
  • Verify intents are enabled in Developer Portal
  • Check logs: pm2 logs openclaw

Bot doesn't respond

  • Ensure Message Content Intent is enabled
  • Check the bot has permissions in the channel
  • Verify prefix matches: grep DISCORD_PREFIX .env

"Missing Permissions" error

Re-invite the bot with correct permissions using the OAuth2 URL generator.

Next Steps

Need Help?

Having trouble with Discord setup? Contact us or check our maintenance plans for professional support.

Need a VPS for Your Bot?

We recommend Hostinger KVM 2 VPS - reliable, fast, and perfect for AI chatbots. Get started with our recommended setup.

Get Hostinger VPS

Need Help With Setup?

Got your VPS? Let us handle the technical work. Professional setup and maintenance for OpenClaw (formerly Clawd.bot).