🎮 OpenClaw Discord集成教程

Bot配置 + 消息自动化 + 社区运营 = 24小时在线的社区管理员

Discord Bot 社区 自动化

📌 为什么用AI管理Discord?

Discord社区需要持续的内容输出和互动。人工运营效率低、覆盖面窄。用OpenClaw管理Discord Bot,可以实现:

🎯 实际效果:妙趣AI的Discord Bot每天自动发送3-5条内容,覆盖AI新闻、技术教程、社区互动,活跃度提升300%。

🤖 Bot配置步骤

Step 1:创建Discord Bot
  1. 访问 Discord Developer Portal
  2. 点击"New Application"创建应用
  3. 进入"Bot"页面,点击"Add Bot"
  4. 复制Bot Token
Step 2:邀请Bot到服务器
# 生成邀请链接(需要以下权限):
# - Send Messages
# - Read Message History
# - Embed Links
# - Attach Files
# - Use Slash Commands

# 邀请链接格式:
https://discord.com/api/oauth2/authorize?client_id=YOUR_BOT_ID&permissions=2147483648&scope=bot
Step 3:配置环境变量
# .env 文件
DISCORD_BOT_TOKEN=your_bot_token_here
DISCORD_GUILD_ID=your_server_id

📤 发送消息

使用curl直接发送

# 发送文本消息
curl -X POST \
  -H "Authorization: Bot $BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content": "🤖 今日AI新闻速递:..."}' \
  https://discord.com/api/v10/channels/CHANNEL_ID/messages

使用message工具

// 发送消息到Discord频道
await message({
  action: "send",
  target: "discord:channel:1483699648890802201",
  message: "🔥 今日头条:OpenClaw发布重大更新!"
});

发送嵌入消息(Embed)

# 使用curl发送Rich Embed
curl -X POST \
  -H "Authorization: Bot $BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "embeds": [{
      "title": "📊 AI新闻日报",
      "description": "今日10条热点新闻",
      "color": 5865f2,
      "fields": [
        {"name": "🔥 热点1", "value": "OpenClaw更新说明...", "inline": false},
        {"name": "🔥 热点2", "value": "NVIDIA安全合作...", "inline": false}
      ],
      "footer": {"text": "妙趣AI · miaoquai.com"}
    }]
  }' \
  https://discord.com/api/v10/channels/CHANNEL_ID/messages

⏰ 定时发送内容

使用cron定时任务

// 每天8:00发送AI新闻
cron.add({
  name: "discord-morning-news",
  schedule: { kind: "cron", expr: "0 8 * * *", tz: "Asia/Shanghai" },
  payload: {
    kind: "agentTurn",
    message: `发送今日AI新闻到Discord综合频道:
    1. 搜索今日AI热点
    2. 整理成简洁的新闻速递
    3. 使用curl发送到频道1483699648890802201`
  }
});

// 每天16:00发送资源推荐
cron.add({
  name: "discord-afternoon-resources",
  schedule: { kind: "cron", expr: "0 16 * * *", tz: "Asia/Shanghai" },
  payload: {
    kind: "agentTurn",
    message: "推荐一个OpenClaw Skills或工具到Discord笔记-资源频道"
  }
});

频道内容规划

时间频道内容类型
08:00综合AI新闻速递
12:00综合热点追踪
16:00笔记-资源工具/教程推荐
20:00题外-话讨论话题
22:00综合每日总结

🔗 相关推荐