Discord 机器人:AI 驱动的服务器管理 - Openclaw Skills

作者:互联网

2026-03-31

AI教程

什么是 Discord 机器人?

Discord 机器人技能是一个轻量级、高性能的桥梁,专为 AI 智能体直接与 Discord 生态系统交互而设计。该集成仅使用 Python 标准库构建,确保了最大的兼容性和安全性,且没有外部依赖的开销。它使开发人员能够构建自主的社区管理器,处理从基础消息传递到复杂的服务器管理的各种任务。

通过利用 Openclaw Skills,该工具为智能体执行程序化操作(如频道创建、成员审核和 Webhook 管理)提供了一种结构化的方式。无论您是在构建支持代理还是自动通知系统,此技能都能为现代基于 Discord 的工作流提供所需的可靠连接。

下载入口:https://github.com/openclaw/skills/tree/main/skills/aiwithabidi/discord-bot

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install discord-bot

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 discord-bot。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

Discord 机器人 应用场景

  • 通过根据智能体检测到的策略违规行为踢出或禁言用户,自动化社区审核。
  • 向多个频道发送系统警报或营销更新的丰富嵌入式通知。
  • 通过自动为新成员分配角色来管理服务器入职。
  • 为基于项目的 Discord 服务器创建和组织频道结构。
  • 获取服务器审计日志以进行自动化安全报告。
Discord 机器人 工作原理
  1. AI 智能体使用存储在环境变量中的安全机器人令牌通过 Discord API 进行身份验证。
  2. 通过 CLI 界面发布命令,指定所需的操作,例如发送消息或列出成员。
  3. 该技能使用 Python 内置的网络功能向 Discord REST API 执行无状态 HTTP 请求。
  4. Discord 处理请求并返回与服务器、频道或操作相关的数据。
  5. 该技能默认以 JSON 格式输出结果,允许 Openclaw Skills 立即解析并根据信息采取行动。

Discord 机器人 配置指南

要开始使用,请确保您拥有来自 Discord 开发人员门户的机器人令牌。

  1. 设置您的环境变量:
export DISCORD_BOT_TOKEN='your_discord_bot_token_here'
  1. 通过列出您的机器人加入的服务器来验证安装:
python3 scripts/discord-bot.py guilds
  1. 要以更易于开发人员阅读的格式查看结果,请使用 human 标志:
python3 scripts/discord-bot.py guilds --human

Discord 机器人 数据架构与分类体系

此技能采用无状态架构设计,确保本地不缓存任何敏感数据。所有数据均在内存中处理并传回给智能体。

组件 描述
身份验证 所有 API 调用均使用 DISCORD_BOT_TOKEN 环境变量。
输出格式 智能体互操作性的标准化 JSON;CLI 使用的可选人类可读文本。
通信 直接向官方 Discord REST API v10 发送 HTTPS 请求。
资源 ID 对服务器、频道和用户使用标准的 Snowflake ID。
name: discord-bot
description: "Discord Bot API integration — manage servers, channels, messages, roles, members, and webhooks via the Discord REST API. Send messages, manage server settings, moderate users, create channels, and handle role assignments. Built for AI agents — Python stdlib only, zero dependencies. Use for Discord server management, bot automation, community management, message sending, moderation, and webhook integrations."
homepage: https://www.agxntsix.ai
license: MIT
compatibility: Python 3.10+ (stdlib only — no dependencies)
metadata: {"openclaw": {"emoji": "??", "requires": {"env": ["DISCORD_BOT_TOKEN"]}, "primaryEnv": "DISCORD_BOT_TOKEN", "homepage": "https://www.agxntsix.ai"}}

?? Discord Bot

Discord Bot API integration — manage servers, channels, messages, roles, members, and webhooks via the Discord REST API.

Features

  • Send messages — text, embeds, files to any channel
  • Channel management — create, update, delete channels
  • Server info — guild details, settings, and statistics
  • Member management — list, kick, ban, role assignment
  • Role management — create, update, assign roles
  • Message operations — send, edit, delete, react, pin
  • Webhook management — create and send via webhooks
  • Thread management — create and manage threads
  • Emoji management — list and manage custom emojis
  • Audit log — view server audit events

Requirements

Variable Required Description
DISCORD_BOT_TOKEN ? API key/token for Discord Bot

Quick Start

# List bot's servers
python3 {baseDir}/scripts/discord-bot.py guilds
# Get server details
python3 {baseDir}/scripts/discord-bot.py guild-get 123456789
# List server channels
python3 {baseDir}/scripts/discord-bot.py channels --guild 123456789
# Create a channel
python3 {baseDir}/scripts/discord-bot.py channel-create --guild 123456789 "general-ch@t" --type text

Commands

guilds

List bot's servers.

python3 {baseDir}/scripts/discord-bot.py guilds

guild-get

Get server details.

python3 {baseDir}/scripts/discord-bot.py guild-get 123456789

channels

List server channels.

python3 {baseDir}/scripts/discord-bot.py channels --guild 123456789

channel-create

Create a channel.

python3 {baseDir}/scripts/discord-bot.py channel-create --guild 123456789 "general-ch@t" --type text

channel-update

Update channel.

python3 {baseDir}/scripts/discord-bot.py channel-update 987654321 '{"name":"announcements","topic":"Important updates"}'

send

Send a message.

python3 {baseDir}/scripts/discord-bot.py send --channel 987654321 "Hello from the bot!"

send-embed

Send embed message.

python3 {baseDir}/scripts/discord-bot.py send-embed --channel 987654321 '{"title":"Update","description":"New feature released","color":5814783}'

messages

List channel messages.

python3 {baseDir}/scripts/discord-bot.py messages --channel 987654321 --limit 20

message-edit

Edit a message.

python3 {baseDir}/scripts/discord-bot.py message-edit --channel 987654321 --message 111222333 "Updated text"

message-delete

Delete a message.

python3 {baseDir}/scripts/discord-bot.py message-delete --channel 987654321 --message 111222333

react

Add reaction to message.

python3 {baseDir}/scripts/discord-bot.py react --channel 987654321 --message 111222333 --emoji ??

members

List server members.

python3 {baseDir}/scripts/discord-bot.py members --guild 123456789 --limit 50

roles

List server roles.

python3 {baseDir}/scripts/discord-bot.py roles --guild 123456789

role-assign

Assign role to member.

python3 {baseDir}/scripts/discord-bot.py role-assign --guild 123456789 --user 444555666 --role 777888999

webhooks

List channel webhooks.

python3 {baseDir}/scripts/discord-bot.py webhooks --channel 987654321

Output Format

All commands output JSON by default. Add --human for readable formatted output.

# JSON (default, for programmatic use)
python3 {baseDir}/scripts/discord-bot.py guilds --limit 5

# Human-readable
python3 {baseDir}/scripts/discord-bot.py guilds --limit 5 --human

Script Reference

Script Description
{baseDir}/scripts/discord-bot.py Main CLI — all Discord Bot operations

Data Policy

This skill never stores data locally. All requests go directly to the Discord Bot API and results are returned to stdout. Your data stays on Discord Bot servers.

Credits


Built by M. Abidi | agxntsix.ai YouTube | GitHub Part of the AgxntSix Skill Suite for OpenClaw agents.

?? Need help setting up OpenClaw for your business? Book a free consultation