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

# Basic

> Discord Bot Run an Agno agent as a Discord bot with DiscordClient.

```python basic.py theme={null}
"""
Discord Bot
Run an Agno agent as a Discord bot with DiscordClient.

Prerequisites: OPENAI_API_KEY, DISCORD_BOT_TOKEN, and a Discord bot with
message-content intent and thread permissions enabled.
Run: .venvs/demo/bin/python cookbook/integrations/discord/basic.py
Try: Send the bot a direct message or mention it in a server channel.
"""

import discord
from agno.agent import Agent
from agno.integrations.discord import DiscordClient
from agno.models.openai import OpenAIResponses

# ---------------------------------------------------------------------------
# Create Discord Bot
# ---------------------------------------------------------------------------

discord_assistant = Agent(
    name="Discord Assistant",
    model=OpenAIResponses(id="gpt-5.5"),
    add_history_to_context=True,
    num_history_runs=3,
)

discord_intents = discord.Intents.default()
discord_intents.message_content = True
discord_bot = discord.Client(intents=discord_intents)
discord_client = DiscordClient(agent=discord_assistant, client=discord_bot)


# ---------------------------------------------------------------------------
# Run Discord Bot
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    discord_client.serve()
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno discord.py openai
```

**2. Export environment variables**

```bash Mac/Linux theme={null}
export DISCORD_BOT_TOKEN="your_discord_bot_token_here"
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:DISCORD_BOT_TOKEN="your_discord_bot_token_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Configure the Discord bot**

Enable the Message Content privileged intent. Install the bot with View Channels, Send Messages, Read Message History, Create Public Threads, and Send Messages in Threads permissions.

**4. Run the example**

Save the code above as `basic.py`, then run:

```bash theme={null}
python basic.py
```

Full source: [cookbook/integrations/discord/basic.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/integrations/discord/basic.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.