Development
This section is for people who want to read, extend, debug, or contribute to discord-bot-rs.
Where to start
- New to the codebase? Start with the Codebase Tour. It walks every module in
src/and explains responsibilities, key types, and entry points. ~3000 words; treat it as your map. - Want to run the bot without Docker? Building Locally covers the cargo workflow, system dependencies, and how to point the binary at a local PostgreSQL.
- Want to write code? Contributing Workflow covers fork-and-PR, the pre-PR checklist, what CI runs, and how reviews work. Pair it with the top-level CONTRIBUTING.md for dev setup and contribution terms.
- Stuck on a bug? Debugging covers
RUST_LOG, common failure modes, and where to look when the bot misbehaves.
How-to guides
When you have a specific change in mind:
- Adding a Command — every user-facing command in this bot is a prefix subcommand of the parent
mcommand. This guide walks through writing a new one and registering it correctly. The #1 gotcha is forgetting the entry insrc/commands/mod.rs. - Adding a Feature Module — the bigger version of “adding a command.” Covers creating a new top-level module under
src/, wiring its config intoInstanceConfig, hooking event handlers, and integrating with theDatastruct. - Adding an MCP Tool — the MCP server in
src/mcp/exposes Discord management tools to clients like Claude Code. This guide shows how to add a new tool, including the schema, handler, and#[tool]macro.
Testing
Testing describes the current state honestly: limited automated coverage today, with a clear path for adding more. The mcp-gateway crate has unit tests for routing; the main crate compiles in CI but has no test suite to speak of yet. Contributions of tests are very welcome.
Architecture context
These dev pages assume you’ve at least skimmed the Architecture Overview. If you haven’t, start there — it has the top-level component diagram, the Data struct’s role, and the multi-instance model. The architecture pages are reference material; the dev pages are how-to.
Tooling expectations
Every PR runs through CI: cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo check, cargo test, and a docker build of both Dockerfiles. Run these locally before pushing and you’ll save yourself a round trip:
cargo fmt
cargo clippy --all-targets -- -D warnings
cargo test
cd mcp-gateway && cargo fmt && cargo clippy --all-targets -- -D warnings && cargo test
Rust formatting is hard tabs, width 4 (rustfmt.toml). Don’t fight the formatter.