packages/examples/discord/README.md
Full-featured Discord AI agents using elizaOS, available in TypeScript, Python, and Rust.
/ping, /about, /help)# Install all dependencies
bun install
bun run build
cd examples/discord
cp env.example .env
# Edit .env with your credentials
Required variables:
DISCORD_APPLICATION_ID - Your Discord application IDDISCORD_API_TOKEN - Your bot tokenOPENAI_API_KEY - Your OpenAI API keyChoose your preferred language:
cd typescript
bun install
bun start
# or for development with hot reload:
bun dev
cd python
pip install -r requirements.txt
python agent.py
cd rust/discord-agent
cargo run --release
examples/discord/
āāā env.example # Environment template
āāā README.md # This file
āāā typescript/ # TypeScript implementation
ā āāā agent.ts # Main entry point
ā āāā character.ts # Bot personality
ā āāā handlers.ts # Event handlers
ā āāā package.json
ā āāā __tests__/ # Tests
āāā python/ # Python implementation
ā āāā agent.py # Main entry point
ā āāā character.py # Bot personality
ā āāā handlers.py # Event handlers
ā āāā requirements.txt
ā āāā tests/ # Tests
āāā rust/ # Rust implementation
āāā discord-agent/
āāā Cargo.toml
āāā src/
ā āāā main.rs # Main entry point
ā āāā character.rs # Bot personality
ā āāā handlers.rs # Event handlers
āāā tests/ # Tests
Edit the character file for your language:
typescript/character.tspython/character.pyrust/discord-agent/src/character.rsEdit the handlers file to add new slash commands:
typescript/handlers.tspython/handlers.pyrust/discord-agent/src/handlers.rsConfigure bot behavior in the character settings:
{
"discord": {
"shouldIgnoreBotMessages": true,
"shouldRespondOnlyToMentions": true
}
}
| Command | Description |
|---|---|
/ping | Check if the bot is online |
/about | Learn about the bot |
/help | Show available commands |
# TypeScript
cd typescript && bun test
# Python
cd python && pytest
# Rust
cd rust/discord-agent && cargo test
DISCORD_API_TOKEN is correctThis example can work alongside the Telegram example. Both share the same .env file and can run simultaneously for a multi-platform bot experience.
# Run Discord bot
cd examples/discord && bun start &
# Run Telegram bot (in another terminal)
cd examples/telegram && bun start &
MIT