> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord

**DiscordTools** 允许代理在 Discord 中发送消息、读取消息历史记录、管理频道以及删除消息。

## 先决条件

以下示例需要一个 Discord 机器人令牌，可以从[此处](https://discord.com/developers/applications)获取。

```shell theme={null}
export DISCORD_BOT_TOKEN=***
```

## 示例

```python cookbook/tools/discord.py theme={null}
from agno.agent import Agent
from agno.tools.discord import DiscordTools

agent = Agent(
    tools=[DiscordTools()],
    show_tool_calls=True,
    markdown=True,
)

agent.print_response("Send 'Hello World!' to channel 1234567890", markdown=True)
```

## Toolkit 参数

| 参数                          | 类型     | 默认值    | 描述                     |
| --------------------------- | ------ | ------ | ---------------------- |
| `bot_token`                 | `str`  | -      | 用于身份验证的 Discord 机器人令牌。 |
| `enable_messaging`          | `bool` | `True` | 是否启用向频道发送消息。           |
| `enable_history`            | `bool` | `True` | 是否启用从频道检索消息历史记录。       |
| `enable_channel_management` | `bool` | `True` | 是否启用获取频道信息和列出频道。       |
| `enable_message_management` | `bool` | `True` | 是否启用从频道删除消息。           |

## Toolkit 函数

| 函数                     | 描述                                    |
| ---------------------- | ------------------------------------- |
| `send_message`         | 向指定频道发送消息。返回成功或错误消息。                  |
| `get_channel_info`     | 检索指定频道的信息。以 JSON 字符串形式返回频道信息。         |
| `list_channels`        | 列出指定服务器（guild）中的所有频道。以 JSON 格式返回频道列表。 |
| `get_channel_messages` | 从指定频道检索消息历史记录。以 JSON 字符串形式返回消息。       |
| `delete_message`       | 按 ID 删除指定频道中的特定消息。返回成功或错误消息。          |

## 开发者资源

* 查看[工具](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/discord.py)
* 查看[食谱](https://github.com/agno-agi/agno/blob/main/cookbook/tools/discord.py)
