Discord

Send messages, read history, and list channels and read channel metadata in Discord with DiscordTools.

DiscordTools enable an agent to send messages, read message history, list channels and read channel metadata, and delete messages in Discord.

Prerequisites

The following example requires the requests and openai libraries and a Discord bot token which can be obtained from here.

uv pip install -U agno requests openai
export DISCORD_BOT_TOKEN=***

Install the bot in your server and grant access to the target channel, including View Channel, Send Messages, and Read Message History for the operations used below. Enable the Message Content intent where required to read message text. Replace the sample channel ID with a real channel ID; server queries similarly require a real guild ID.

Example

cookbook/91_tools/discord_tools.py
from agno.agent import Agent
from agno.tools.discord import DiscordTools

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

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

Toolkit Params

ParameterTypeDefaultDescription
bot_tokenOptional[str]NoneDiscord bot token for authentication. Falls back to the DISCORD_BOT_TOKEN environment variable.
enable_send_messageboolTrueWhether to enable sending messages to channels.
enable_get_channel_messagesboolTrueWhether to enable retrieving message history from channels.
enable_get_channel_infoboolTrueWhether to enable fetching channel info.
enable_list_channelsboolTrueWhether to enable listing channels in a server.
enable_delete_messageboolTrueWhether to enable deleting messages from channels.
allboolFalseEnable all functions.

Toolkit Functions

FunctionDescription
send_messageSend a message to a specified channel. Returns a success or error message.
get_channel_infoRetrieve information about a specified channel. Returns the channel info as a JSON string.
list_channelsList all channels in a specified server (guild). Returns the list of channels as JSON.
get_channel_messagesRetrieve one bounded page of message history from a specified channel; pagination is not exhausted automatically. Returns messages as a JSON string.
delete_messageDelete a specific message by ID from a specified channel. Returns a success or error message.

Developer Resources