$cd ../tutorials/
π¬ Messagingv1.0+20 min setup
$ cat discord-setup.md
openclaw.connect('discord')
/** Turn your Discord server into an AI-powered community hub */
// What becomes possible
$ @bot what's wrong with this Python code?
// In-channel code review
$ /summarize #general
// Auto-summarize channel history
$ !ai explain Docker volumes
// Custom trigger prefix
$ Mod log auto-summaries
// Reduce admin workload
step_01_create_bot.md
## Step 1: Create a Discord Bot
1.
Open Discord Developer Portal
Go to discord.com/developers/applications and log in.
2.
New Application β Bot β Add Bot
Give your bot a name β this will be its display name in your server. Save it.
3.
Copy the Bot Token
Click 'Reset Token' β 'Copy'. This is shown only once. Store it securely.
4.
Enable Message Content Intent
Bot β Privileged Gateway Intents β toggle Message Content Intent ON. Required to read messages.
5.
Invite Bot to your server
OAuth2 β URL Generator β check bot + applications.commands β permissions: Send Messages, Read Message History β open the generated URL.
step_02_config.yaml
## Step 2: Configure OpenClaw
# openclaw/config.yaml
channels:
discord:
enabled: true
token: "YOUR_BOT_TOKEN_HERE"
trigger_prefix: "!ai" # or use @mention
respond_in_channels:
- "general"
- "ai-chat"
$ openclaw start
# β Discord bot connected. Serving 2 channels.
example_chat.log
π¬ Live Example
Alice Β· #general
!ai explain Python's GIL like I'm a senior eng
OpenClaw Bot Β· just now
GIL (Global Interpreter Lock) is a mutex in CPython that ensures only one thread executes Python bytecode at a time. For I/O-bound work, threading or asyncio works fine since GIL is released during blocking I/O calls.
Bob Β· #general
/summarize #announcements
OpenClaw Bot Β· just now
Last 7 days in #announcements: New #ai-chat channel launched. Weekly Friday voice event announced. Bot now supporting /ask slash command.