docs: make English the default docs language and fix link paths

This commit is contained in:
zhayujie
2026-05-31 17:52:22 +08:00
parent 126649f70f
commit 7bf4ef3d05
231 changed files with 8999 additions and 8974 deletions

View File

@@ -1,51 +1,51 @@
---
title: Discord
description: CowAgent 接入 Discord Bot
description: Integrate CowAgent with a Discord Bot
---
> 通过 Discord Bot **Gateway 长连接** 接入 CowAgent支持私聊DM与服务器频道@机器人 / 回复机器人触发。Gateway 基于 WebSocket 长连接,无需公网 IP 与回调地址,开箱即用。
> Integrate CowAgent into Discord via a Discord Bot using the **Gateway** (persistent WebSocket). Supports direct messages (DM) and server channels (triggered by @mention or replying to the bot). The Gateway uses a persistent WebSocket connection — no public IP or callback URL required, works out of the box.
## 一、接入步骤
## 1. Setup
### 步骤一:创建 Discord 应用与 Bot
### Step 1: Create a Discord Application and Bot
1. 打开 [Discord 开发者后台](https://discord.com/developers/applications),点击 **New Application**,填写名称(如 `CowAgent`)并创建。
2. 左侧菜单进入 **Bot** 页面,点击 **Reset Token** 生成 Bot Token复制并妥善保存仅显示一次
1. Open the [Discord Developer Portal](https://discord.com/developers/applications), click **New Application**, enter a name (e.g. `CowAgent`), and create it.
2. Go to the **Bot** page in the left sidebar, click **Reset Token** to generate a Bot Token, then copy and store it safely (shown only once).
<Tip>
这个 Token 等同于 Bot 的密码,请勿泄露。若意外泄漏,在 Bot 页面再次点击 **Reset Token** 重置即可。
This token is your bot's password — keep it secret. If it leaks, click **Reset Token** again on the Bot page to regenerate it.
</Tip>
### 步骤二:开启 Message Content Intent
### Step 2: Enable the Message Content Intent
私聊与频道读取文本均依赖该权限。
Reading message text in both DMs and channels depends on this privileged intent.
1. **Bot** 页面下方找到 **Privileged Gateway Intents**
2. 打开 **Message Content Intent** 开关并保存。
1. On the **Bot** page, find **Privileged Gateway Intents**.
2. Turn on **Message Content Intent** and save.
<Note>
未开启该开关时,机器人收到的消息内容会为空,导致无响应。
Without this intent enabled, incoming message content will be empty and the bot will not respond.
</Note>
### 步骤三:邀请 Bot 进入服务器
### Step 3: Invite the Bot to a Server
1. 左侧菜单进入 **OAuth2 → URL Generator**
2. **Scopes** 勾选 `bot`
3. **Bot Permissions** 至少勾选:`Send Messages``Read Message History``Attach Files``View Channels`
4. 复制底部生成的授权链接,在浏览器打开,选择目标服务器完成授权。
1. Go to **OAuth2 → URL Generator** in the left sidebar.
2. Under **Scopes**, check `bot`.
3. Under **Bot Permissions**, check at least: `Send Messages`, `Read Message History`, `Attach Files`, `View Channels`.
4. Copy the generated authorization URL at the bottom, open it in a browser, and authorize it for your target server.
<Note>
仅需私聊DM可跳过此步但仍需先在任意共同服务器中与机器人建立 DM 通道,或由用户主动私聊机器人。
You can skip this step if you only need DMs, but you still need a DM channel with the bot (e.g. the user messages the bot directly).
</Note>
### 步骤四:接入 CowAgent
### Step 4: Connect to CowAgent
<Tabs>
<Tab title="Web 控制台(推荐)">
打开 Web 控制台本地链接http://127.0.0.1:9899 ),选择 **通道** 菜单,点击 **接入通道**,选择 **Discord**,填入 Bot Token点击接入即可。
<Tab title="Web Console (Recommended)">
Open the Web Console (default `http://127.0.0.1:9899`), go to **Channels**, click **Add Channel**, choose **Discord**, paste the Bot Token, and click connect.
</Tab>
<Tab title="配置文件">
`config.json` 中添加以下配置后启动:
<Tab title="Config File">
Add the following to `config.json` and start Cow:
```json
{
@@ -55,39 +55,39 @@ description: 将 CowAgent 接入 Discord Bot
}
```
| 参数 | 说明 | 默认值 |
| Key | Description | Default |
| --- | --- | --- |
| `discord_token` | 开发者后台 Bot 页面生成的 Bot Token | - |
| `discord_group_trigger` | 频道触发方式:`mention_or_reply`@或回复机器人)/ `mention_only`(仅@ / `all`(所有消息) | `mention_or_reply` |
| `discord_token` | Bot Token generated on the Bot page of the Developer Portal | - |
| `discord_group_trigger` | Channel trigger: `mention_or_reply` (@ or reply to bot) / `mention_only` (@ only) / `all` (all messages) | `mention_or_reply` |
</Tab>
</Tabs>
启动 Cow 后,日志中出现以下输出即表示接入成功:
The integration is ready when you see logs like:
```
[Discord] Bot logged in as CowAgent#1234 (id=123456789)
[Discord] ✅ Discord bot ready, listening for messages
```
## 二、功能说明
## 2. Capabilities
| 功能 | 支持情况 |
| Feature | Support |
| --- | --- |
| 私聊(DM | ✅ |
| 服务器频道(@机器人 / 回复机器人) | ✅ |
| 文本消息 | ✅ 收发 |
| 图片消息 | ✅ 收发 |
| 文件消息 | ✅ 收发(PDF / Word / Excel 等) |
| Direct message (DM) | ✅ |
| Server channel (@bot / reply to bot) | ✅ |
| Text messages | ✅ send / receive |
| Image messages | ✅ send / receive |
| File messages | ✅ send / receive (PDF / Word / Excel, etc.) |
<Note>
Discord 单条消息上限为 2000 字符,超长回复会自动按换行拆分为多条发送。
A single Discord message is capped at 2000 characters; long replies are automatically split across multiple messages by line breaks.
</Note>
## 三、使用
## 3. Usage
完成接入后:
Once connected:
- **私聊(DM**:在服务器成员列表中找到你的机器人,点击头像直接发消息对话。
- **频道**:在已邀请机器人的频道中,使用 `@你的机器人 你好` 或 **回复机器人的某条消息** 触发对话。
- **Direct message (DM)**: find your bot in the server member list, click its avatar, and message it directly.
- **Channel**: in a channel where the bot is invited, trigger it with `@your-bot hello` or by **replying to one of the bot's messages**.
发送图片或文件时,可以在附件的输入框中 **添加文字说明**(描述/问题)一并发送,机器人会结合附件回答。也支持先发附件再发问题,两条消息会自动合并提问。
When sending an image or file, you can **add a text caption** (description / question) in the attachment input — the bot will answer based on both. Sending an attachment first and then a follow-up question also works; the two messages are merged automatically.