Full-featured TypeScript Discord AI agent using elizaOS.
- 🤖 Responds to @mentions and replies
- ⚡ Slash commands (
/ping,/about,/help) - 💾 Persistent memory via SQL database
- 🧠 OpenAI-powered language understanding
- 🎯 Configurable response behavior
# Install all dependencies
bun install
bun run build- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" section and create a bot
- Enable "Message Content Intent" (required for reading messages)
- Copy the Bot Token
- Invite the bot to your server using OAuth2 URL Generator:
- Select "bot" scope
- Select permissions: Send Messages, Read Message History, Add Reactions
cd packages/examples/discord
cp env.example .env
# Edit .env with your credentialsRequired variables:
DISCORD_APPLICATION_ID- Your Discord application IDDISCORD_API_TOKEN- Your bot tokenOPENAI_API_KEY- Your OpenAI API key
cd packages/examples/discord
bun install
bun run start
# or for development with hot reload:
bun run devpackages/examples/discord/
├── env.example # Environment template
├── README.md # This file
├── agent.ts # Main entry point
├── character.ts # Bot personality
├── handlers.ts # Event handlers
├── package.json
└── tsconfig.json
Edit character.ts.
Edit handlers.ts to add new slash commands.
Configure 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 |
cd packages/examples/discord
bun run test- Ensure "Message Content Intent" is enabled in Discord Developer Portal
- Check that the bot has proper permissions in your server
- Verify
DISCORD_API_TOKENis correct
- Commands may take up to an hour to propagate globally
- For instant testing, use guild-specific commands in development
- Discord has rate limits; the bot handles these automatically
- If you see 429 errors, reduce message frequency
This 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 packages/examples/discord && bun start &
# Run Telegram bot (in another terminal)
cd packages/examples/telegram && bun start &MIT