MCPcopy Index your code
hub / github.com/MrMcEpic/discord-bot-rs

github.com/MrMcEpic/discord-bot-rs @v0.18.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.18.0 ↗ · + Follow
749 symbols 1,874 edges 67 files 95 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

discord-bot-rs

A multi-instance Discord bot framework written in Rust.

CI Docs License: AGPL-3.0-or-later Rust ghcr.io


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.

Features

Multi-instance, one binary

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

AI chat with real tool use

@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.

Music with passthrough audio

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.

Built-in games

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.

Minecraft integration

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.

MCP server for Claude Code

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.

Quick Start

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.

Architecture

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

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/.

Feature Reference

Documentation

Full documentation: https://mrmcepic.github.io/discord-bot-rs/

Highlights:

  • Getting Started — install, quickstart, first-bot tutorial, setup verification
  • Configuration — env vars, config.toml reference, secrets management
  • Features — deep dive per feature
  • Architecture — how it's built, with diagrams
  • Development — codebase tour, adding a command, contributing workflow
  • Reference — command list, MCP tool catalog, FAQ, glossary

Contributing

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.

License

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.

Acknowledgements

This project stands on the shoulders of excellent open-source work:

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 482
Method 153
Class 105
Enum 8
Interface 1

Languages

Rust100%

Modules by API surface

src/mcp/tools.rs132 symbols
src/ai/providers/mod.rs101 symbols
src/instance_config.rs45 symbols
src/music/player.rs33 symbols
src/ai/chat.rs30 symbols
src/connections/game.rs26 symbols
src/db/queries.rs22 symbols
src/ai/providers/configured.rs21 symbols
src/wordle/game.rs20 symbols
mcp-gateway/src/backend.rs20 symbols
src/util/duration.rs16 symbols
src/commands/music.rs15 symbols

Datastores touched

discord_botDatabase · 1 repos
discord_bot_dbDatabase · 1 repos

For agents

$ claude mcp add discord-bot-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page