A multi-instance Discord bot framework written in Rust.
discord-bot-rs is a batteries-included Discord bot framework you can self-host. Run one bot or fifty from a single Rust binary, each with its own personality, database schema, and feature set. Ships with AI chat, music, games, moderation, a Minecraft module, and a Model Context Protocol server for programmatic Discord management from Claude Code or any MCP client.
One Rust binary runs any number of bot instances simultaneously, each with its own Discord application, personality file, database schema, and feature flags. Adding a bot is copying a directory and editing three text files.
cp -r instances/example instances/mybot
# Edit instances/mybot/.env and instances/mybot/config.toml
INSTANCE_DIR=./instances/mybot docker compose up -d
@mention the bot and it replies with a DeepSeek-powered conversation shaped by the personality file you wrote. Gemini is the fallback provider when DeepSeek errors. The AI can invoke tools: web search, moderation actions, music control, user confirmations.
yt-dlp and ffmpeg produce a 256 kbps OGG/Opus stream that songbird plays without transcoding. Very low CPU. Supports YouTube, SoundCloud, Bandcamp, and anything yt-dlp knows about. Interactive button controls, queue with loop and shuffle, auto-leave on empty voice channel.
Daily Wordle, Connections (group-by-category), and virtual stock trading with real-time Finnhub data. Each game has its own schema isolation per instance, so running two bots doesn't share state.
Link Discord accounts to Minecraft accounts via !m verify. Optional donator role sync polls your Tebex-backed MC server and applies Discord roles based on tier. Optional real-time chargeback alerts ship an interactive staff embed the moment a player charges back.
An embedded Model Context Protocol server exposes 51 Discord management tools — guilds, channels, roles, members, messages, reactions, voice, invites, custom emoji, webhooks, DMs. Plug Claude Code into http://localhost:9090/mcp and manage your server from an AI assistant. A companion mcp-gateway service routes tool calls across multiple bot instances when you run more than one. The full catalog lives at docs/reference/mcp-tool-catalog.md.
git clone https://github.com/MrMcEpic/discord-bot-rs.git
cd discord-bot-rs
cp -r instances/example instances/mybot
cp instances/mybot/.env.example instances/mybot/.env
# Edit instances/mybot/.env with your Discord token + API keys
INSTANCE_DIR=./instances/mybot docker compose up -d
The full ten-minute walkthrough is in docs/getting-started/quickstart.md. First-timers who want the hand-held version should start with the First Bot Tutorial.
graph TB
subgraph "Bot Process"
Gateway[Discord Gateway
serenity]
Handler[Event Handler
poise]
Commands[Commands
src/commands/]
AI[AI Pipeline
src/ai/]
Music[Music Player
src/music/]
Games[Games
wordle / connections / stocks]
DB[(PostgreSQL
sqlx, schema-per-instance)]
MCP[MCP Server
src/mcp/ + axum]
end
Discord[Discord API] <--> Gateway
Gateway --> Handler
Handler --> Commands
Handler --> AI
Handler --> Music
Commands --> DB
AI --> DB
Games --> DB
Handler --> Games
Claude[Claude Code / MCP Client] --> MCP
MCP --> Handler
Each bot instance is one process with its own shared Data struct holding a PostgreSQL pool, configuration, AI state, per-guild music players, and more. Commands reach state through ctx.data(). Events flow Discord → serenity → poise → handlers → database. See docs/architecture/ for the deep dive, including multi-instance topology, the AI pipeline, the music pipeline, the MCP gateway, and the database schema.
Configuration is split across three files per instance:
| File | What lives here | Documented in |
|---|---|---|
.env |
Secrets, tokens, API keys, database connection | docs/configuration/environment-variables.md |
config.toml |
Bot identity, command prefix, feature flags | docs/configuration/instance-config.md |
personality.txt |
AI system prompt (free-form prose) | docs/configuration/personality.md |
The full configuration model, including how instances are isolated and how to run more than one, is in docs/configuration/.
Full documentation: https://mrmcepic.github.io/discord-bot-rs/
Highlights:
Contributions welcome. Read CONTRIBUTING.md for the dev setup, code style, and PR workflow. The Codebase Tour is the best place to start if you're new to the project. Security issues should follow SECURITY.md — please do not open public issues for vulnerabilities.
AGPL-3.0-or-later. See LICENSE for the full text.
In plain English: you can run, modify, and distribute this bot freely. If you run a modified version as a public service (including a hosted Discord bot others interact with), you must publish your changes under the same license. The copyleft extends over the network, which is the "A" in AGPL.
If this restriction is a problem for your use case, let's talk — open an issue.
This project stands on the shoulders of excellent open-source work:
$ claude mcp add discord-bot-rs \
-- python -m otcore.mcp_server <graph>