basic.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export environment variables
4
Run the example
Save the code above as
basic.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Runs a simple Agno-powered Discord bot.
"""
Basic Discord Agent
===================
Runs a simple Agno-powered Discord bot.
"""
from agno.agent import Agent
from agno.integrations.discord import DiscordClient
from agno.models.openai import OpenAIChat
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
basic_agent = Agent(
name="Basic Agent",
model=OpenAIChat(id="gpt-4o"),
add_history_to_context=True,
num_history_runs=3,
add_datetime_to_context=True,
)
discord_agent = DiscordClient(basic_agent)
# ---------------------------------------------------------------------------
# Run Discord Bot
# ---------------------------------------------------------------------------
if __name__ == "__main__":
discord_agent.serve()
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno discord discord.py openai
Export environment variables
export DISCORD_BOT_TOKEN="your_discord_bot_token_here"
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:DISCORD_BOT_TOKEN="your_discord_bot_token_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run the example
basic.py, then run:python basic.py
Was this page helpful?