先决条件
以下示例需要一个 Discord 机器人令牌,可以从此处获取。示例
cookbook/tools/discord.py
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
export DISCORD_BOT_TOKEN=***
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)
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
bot_token | str | - | 用于身份验证的 Discord 机器人令牌。 |
enable_messaging | bool | True | 是否启用向频道发送消息。 |
enable_history | bool | True | 是否启用从频道检索消息历史记录。 |
enable_channel_management | bool | True | 是否启用获取频道信息和列出频道。 |
enable_message_management | bool | True | 是否启用从频道删除消息。 |
| 函数 | 描述 |
|---|---|
send_message | 向指定频道发送消息。返回成功或错误消息。 |
get_channel_info | 检索指定频道的信息。以 JSON 字符串形式返回频道信息。 |
list_channels | 列出指定服务器(guild)中的所有频道。以 JSON 格式返回频道列表。 |
get_channel_messages | 从指定频道检索消息历史记录。以 JSON 字符串形式返回消息。 |
delete_message | 按 ID 删除指定频道中的特定消息。返回成功或错误消息。 |