Discord
当你希望在 Discord 私信或 server 中访问 Agent 时,可以连接 Discord。
前提条件
- 已有 Cloud Agents Agent。
- 有权限创建 Discord application。
- 有权限把 bot 邀请到目标 server。
创建 Discord application
- 打开 Discord Developer Portal。
- 创建新的 application。
- 打开 Bot 并创建 bot user。
- Reset 并复制 bot token。
- 在 Privileged Gateway Intents 下启用 Message Content Intent。
Message Content Intent 是必需的。如果没有启用,Cloud Agents 可以连接 bot,但无法读取用户 prompt。
邀请 bot
打开 OAuth2 URL Generator:
- 选择
botscope。 - 选择这些 bot permissions:
| Permission | 用途 |
|---|---|
| View Channels | 让 bot 看到目标频道中的消息。 |
| Send Messages | 发送 Agent 回复。 |
| Read Message History | 读取 Gateway 投递的消息上下文。 |
复制生成的 URL,打开它,并把 bot 邀请到 server。
连接到 Cloud Agents
- 打开 Settings -> Channels。
- 创建新渠道并选择 Discord。
- 选择要接收消息的 Agent。
- 输入标签并粘贴 bot token。
- 可以选择限制到指定 server。
- 创建渠道。
- 运行渠道测试。
Discord 不需要你在 Discord 中粘贴 inbound URL。
推荐设置
| 设置 | 建议 |
|---|---|
| Allowed servers | 当 bot 加入多个 server 时,限制到已知 server ID。 |
| Mention only | server 中建议开启,让 Agent 只在被 mention 时回复。DM 仍然可用。 |
| Shared session | 默认关闭,除非 server 频道中的所有人都应该共享同一段对话。 |
| Progress mode | 如果希望 Agent 工作时更新同一条消息,使用 preview。 |
验证
打开渠道详情页并运行 Test。健康的渠道会确认 bot 身份和 Message Content Intent 状态。
排查问题
- Message Content Intent 未启用:在 Developer Portal 中启用,然后重新测试渠道。
- Bot 已连接但忽略 server 消息:mention bot,或关闭 mention-only 模式。
- 某个 server 的消息被忽略:检查 allowed server 列表。
- Bot 无法发送回复:用 View Channels、Send Messages 和 Read Message History 权限重新邀请它。