SuperAPI AI 工具集

discord-openapi-skill

编程与开发

查看项目

更新于 10-15 22:14

技能介绍

用途:通过 uxc 配合 Discord OpenAPI 规范执行 Discord REST 操作,复用 uxc 的认证与错误处理能力。

前提:uxc 已安装且在 PATH 中;可访问 https://discord.com/api/v10;可获取 OpenAPI 规范 https://raw.githubusercontent.com/discord/discord-api-spec/main/specs/openapi.json;需机器人令牌(推荐)或 OAuth2 用户认证(功能有限)。

认证:机器人令牌提供读取消息、管理服务器、发送消息等完整权限。创建机器人应用后生成令牌并配置:uxc auth credential set discord-bot --auth-type api_key --header "Authorization=Bot {{secret}}" --secret "YOUR_BOT_TOKEN_HERE",再绑定到 discord.com 的 /api/v10。OAuth2 用户认证无法通过 HTTP API 读取频道消息,不能发消息或管理服务器,仅可读取用户资料、邮箱、连接和服务器列表。

使用方式:默认使用固定链接命令 command -v discord-openapi-cli;若缺失则执行 uxc link discord-openapi-cli https://discord.com/api/v10 --schema-url https://raw.githubusercontent.com/discord/discord-api-spec/main/specs/openapi.json。用 -h 查看操作,用 get:/users/@me -h 之类查看单个操作 schema。执行示例:无认证连通性检查 discord-openapi-cli get:/gateway;键值传参 discord-openapi-cli get:/guilds/{guild_id}/channels guild_id=GUILD_ID;位置 JSON discord-openapi-cli post:/channels/{channel_id}/messages '{"channel_id":"CHANNEL_ID","content":"Hello from uxc"}'。认证异常时用 uxc auth binding match https://discord.com/api/v10 检查绑定。

限制:入站事件走 Gateway WebSocket 而非 REST,可用 uxc subscribe start 搭配 --transport discord-gateway 订阅,示例意图 4609 为 GUILDS|GUILD_MESSAGES|DIRECT_MESSAGES。写入或高风险操作(如发消息、删除/更新、审核端点)需用户明确确认。自动化建议使用 JSON 输出,避免 --text。缺失信息:未提供具体计费、平台限制或效果说明。