@clisbot/channels-discord

中文文档
2.2.3发布于 2026/11/05TypeScriptES Module近 30 天下载 4080

In-repo Discord channel vertical (goal ledger slice 13). Ported from extensions/discord/src@5d8067a4483: the hand-rolled Discord REST/gateway client (src/internal), the send/action/component/markdown closure, and the Fusion boundary adapters. Third-party

原始使用文档
文档目录6 节
  1. What a live test needs
  2. Discord application
  3. Test surfaces
  4. Minimal account config
  5. Supported today
  6. Not supported yet

@clisbot/channels-discord

The in-repo Discord channel vertical (goal ledger slice 13). Ported from extensions/discord/src@5d8067a4483 — see upstream-sync.json for the file-by-file mapping, the deviations (D-DC-0xx) and what is omitted.

Third-party SDKs are upstream's, at upstream's versions: discord-api-types, ws, undici, typebox, mdast-util-from-markdown. Upstream hand-rolls its Discord REST + gateway client in src/internal/ rather than depending on discord.js; that client is carried verbatim.

What a live test needs

Provision these yourself and put them in the repo-root .env. This package never reads .env and no value here is a real credential — only names.

Discord application

  1. Create an application at https://discord.com/developers/applications, add a Bot user, and copy its token into DISCORD_BOT_TOKEN. The application id is decoded from the token, so applicationId in config is only needed when REST application lookup is blocked.
  2. Under Bot → Privileged Gateway Intents, enable Message Content Intent. Without it Discord delivers empty content for guild messages the bot is not mentioned in, and only mention-addressed traffic works. Server Members and Presence stay off — the vertical does not request them unless channels.discord.accounts.<id>.intents asks.
  3. Under OAuth2 → URL generator, select scopes bot and applications.commands, then bot permissions:
    • View Channels, Send Messages, Send Messages in Threads
    • Create Public Threads, Manage Threads
    • Embed Links, Attach Files, Read Message History
    • Add Reactions, Manage Messages (needed for pin/unpin and delete)
    • Use External Emojis (only for discord.emoji-list across guilds)
  4. Invite the bot to a test guild with the generated URL.

Test surfaces

Env varWhat it must be
DISCORD_BOT_TOKENThe bot under test. Never the driver account.
DISCORD_TEST_GUILD_IDThe guild the bot was invited to.
DISCORD_TEST_CHANNEL_IDA guild text channel the bot can read and post in.
DISCORD_TEST_THREAD_IDA thread under that channel (a Discord thread is itself a channel id).
DISCORD_TEST_DM_USER_IDThe user id the bot opens a DM with. That user must share the guild with the bot.
DISCORD_TEST_BOT_USER_IDThe bot's own user id, for the <@id> mention marker and the own-message filter.
DISCORD_DRIVER_BOT_TOKENA second bot, used only as the external sender. Never configure the host with it.

The driver/bot-under-test split is the same rule the Telegram vertical follows (CLAUDE.md, "Required Slack and Telegram E2E roles"): a direct sendText is an outbound smoke test only. The required proof is external sender → gateway → agent turn → reply in the same conversation, then a REST read-back (GET /channels/{id}/messages) matching the returned message id.

Minimal account config

channel: discord
accountId: main
connectionId: <hub connection id>
transport: { mode: gateway }
routes:
  - match: { kind: dm }
    agent: <agent>
    environment: <environment>
  - match: { kind: channel, ids: ["<DISCORD_TEST_CHANNEL_ID>"] }
    agent: <agent>
    environment: <environment>

The bot token lives in the Hub connection's credentials under token, not in this file.

Supported today

Inbound (MESSAGE_CREATE over the gateway): DM, guild text channels and threads; mention detection (explicit <@id> mention or a reply to the bot); own-message and bot-author filtering; durable admission into the Hub ingress queue keyed on the Discord message id, so a gateway RESUME redelivery is dropped rather than replayed.

Outbound: text with upstream's markdown rendering, chunking and mention rewriting; files of any type (one message per file, size-gated); message edit and delete; pin/unpin/list-pins; reactions (add, remove, list); thread create and thread reply; polls; stickers; emoji upload and emoji-list; webhook sends; embeds and message components (buttons, selects) including the presentation adapter; typing indicator; guild/channel/member/role reads and the guild-admin actions upstream gates behind a trusted requester.

Not supported yet

Named here so nothing above is read as more than it is.

  • Voice messages and voice channels — send.voice.ts, voice-message.ts and the whole src/voice tree are omitted (ffmpeg/opus transcoding, @discordjs/voice). The send action's asVoice branch throws (D-DC-004).
  • Activities — src/activities needs a public endpoint the Hub does not expose.
  • Slash commands and interaction callbacks — command deploy and interaction dispatch are carried in src/internal, but nothing registers or routes them yet; button and select clicks do not reach the Hub.
  • Inbound reactions, message edits/deletes, attachments — the gateway transport only normalizes MESSAGE_CREATE. Inbound media is not downloaded.
  • Gateway proxy — a configured proxy is refused loudly rather than silently ignored (D-DC-008).
  • Setup/doctor surfaces — the OpenClaw wizard and doctor trees are omitted; the Hub owns onboarding.

版本与发布记录

@clisbot/channels-discord 共发布 18 个版本,首次发布于 2026/10/10;过去 12 个月发布了 18 个版本。

版本发布日期距今
2.2.3latest2026/11/055 天前
2.2.22026/11/037 天前
2.2.12026/11/019 天前
2.2.02026/10/2714 天前
2.1.82026/10/2218 天前
2.1.72026/10/2219 天前

关于 @clisbot/channels-discord 的常见问题

@clisbot/channels-discord 是什么?

In-repo Discord channel vertical (goal ledger slice 13). Ported from extensions/discord/src@5d8067a4483: the hand-rolled Discord REST/gateway client (src/internal), the send/action/component/markdown closure, and the Fusion boundary adapters. Third-party

如何安装 @clisbot/channels-discord?

在项目目录运行 npm install @clisbot/channels-discord,或使用 pnpm add / yarn add / bun add。

@clisbot/channels-discord 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clisbot/channels-discord 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@clisbot/channels-discord 可以商用吗?

@clisbot/channels-discord 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@clisbot/channels-discord 的下载量有多少?

根据 npm 官方下载统计,@clisbot/channels-discord 在 2026/10/10 – 2026/11/08 这 30 天内被下载 4,080 次,日均约 136 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@clisbot/channels-discord 还在维护吗?

最新版本 2.2.3 发布于 2026/11/05(5 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/10/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。