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.
Introduction
This guide walks you through connecting OpenClaw to Discord, from creating a bot application to inviting it to your server.
Prerequisites
- OpenClaw installed on your VPS
- A Discord account
- Server admin permissions (to invite the bot)
Step 1: Create a Discord Application
- Go to the Discord Developer Portal
- Click New Application
- Name your application (e.g., "My AI Bot")
- Click Create
Step 2: Create a Bot User
- In your application, go to the Bot section
- Click Add Bot
- 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
- In the Bot section, click Reset Token
- Copy the token immediately (you can only see it once)
- 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
-
Go to OAuth2 > URL Generator
-
Select scopes:
botapplications.commands
-
Select bot permissions:
- Read Messages/View Channels
- Send Messages
- Embed Links
- Attach Files
- Read Message History
- Use Slash Commands
-
Copy the generated URL and open it in your browser
-
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
- Create a new channel (e.g., #ai-chat)
- Set permissions so only the bot can send messages
- 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
- Configure system prompts for personality
- Set up monitoring for uptime alerts
- Security hardening for your VPS
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 VPSNeed Help With Setup?
Got your VPS? Let us handle the technical work. Professional setup and maintenance for OpenClaw (formerly Clawd.bot).