A Discord dice rolling bot for tabletop RPGs. Supports complex dice expressions, exploding dice, keep/drop, success counting, and built-in aliases for 30+ game systems.
A complete rewrite of the original DiceMaiden Ruby bot in Rust.
The bot appears in your default public channel with permission to read, send, and manage messages.
Users need the "Use Application Commands" permission to use slash commands.
To restrict the bot to specific channels, go to Server Settings → Integrations → Dice Maiden.
| Command | Description |
|---|---|
/roll <dice> |
Roll dice using RPG notation |
/r <dice> |
Short alias for /roll |
/help [topic] |
Help — topics: basic, alias, system, a5e, aliens, mothership, ol, ess, tdh, cpr, wfrp, tbe |
/purge <count> |
Delete the last 2–100 messages in the channel (requires Manage Messages) |
/roll donate |
Support information |
/roll bot-info |
Version, server count and memory use (requires Administrator) |
/roll 2d6 + 3 # Basic roll with modifier
/roll 4d6 k3 # Keep the 3 highest
/roll 10d6 e6 k8 +4 # Explode 6s, keep 8 highest, add 4
/roll 4d10 t8 ie10 f1 # Success counting with botches
/roll 6 4d6 # Six sets of 4d6
/roll (Fireball) 8d6 ! AOE # Labeled roll with a comment
Full syntax reference and game system aliases →
Requires Rust 1.95+ and a Discord bot token. SQLite is created automatically.
git clone https://github.com/Humblemonk/dicemaiden-rs.git cd dicemaiden-rs cp env.example .env # add your DISCORD_TOKEN cargo build --release cargo run --release
Create your bot at the Discord Developer Portal and invite it with Send Messages, Use Slash Commands, Manage Messages, and Read Message History.
See env.example for the full annotated list.
| Variable | Required | Description |
|---|---|---|
DISCORD_TOKEN |
✓ | Bot token from the Discord developer portal |
DATABASE_URL |
SQLite URL (sqlite:path/to/main.db) — defaults to main.db in the working directory (the checkout root under cargo run), created if missing |
|
GUILD_ID |
Register commands to one guild for instant testing | |
SHARD_COUNT |
Shards for this process — defaults to 1 | |
USE_AUTOSHARDING |
true lets Discord pick the shard count |
|
SHARD_START |
First shard ID (multi-process sharding) | |
TOTAL_SHARDS |
Total shards across all processes (multi-process sharding) | |
MAX_CONCURRENCY |
Hint only — Discord overrides with your bot's real limit | |
RUST_LOG |
Log level — defaults to info |
A SHARD_COUNT, SHARD_START or TOTAL_SHARDS that is set but isn't a whole number stops
startup with an error naming it, before any shard connects (with USE_AUTOSHARDING=true they're
ignored and only warn). A .env line that can't be parsed is logged by its key: it and every
line after it are not loaded.
A production Dockerfile is included — build it directly rather than copying
one out of these docs:
docker build -t dicemaiden-rs .
docker run --env-file .env -v dicemaiden-data:/app dicemaiden-rsThe image's working directory is /app, so the default database is /app/main.db; mount the
volume there (as docker-compose.yml does) or the statistics are lost
with the container. The compose file passes no environment of its own: put .env in
/opt/dicemaiden-rs, which it mounts as /app, and the bot reads it from there at startup.
The bot runs as uid 1000 inside the container, so give it that directory and the .env in it
before the first run (sudo chown -R 1000:1000 /opt/dicemaiden-rs), or it cannot read its
settings or create the database. Under rootless podman, run
podman unshare chown -R 1000:1000 /opt/dicemaiden-rs instead.
Systemd service
[Unit] Description=Dice Maiden After=network-online.target Wants=network-online.target [Service] Type=simple User=dicebot Group=dicebot WorkingDirectory=/opt/dicemaiden-rs Environment=RUST_LOG=info # ProtectSystem=strict leaves only ReadWritePaths writable, so the database must live there. # Create the directory before starting: systemd refuses to start if it is missing. Environment=DATABASE_URL=sqlite:/opt/dicemaiden-rs/data/main.db EnvironmentFile=/opt/dicemaiden-rs/.env ExecStart=/opt/dicemaiden-rs/target/release/dicemaiden-rs Restart=always RestartSec=10 TimeoutStartSec=300 TimeoutStopSec=120 # Security hardening NoNewPrivileges=true ProtectSystem=strict ProtectHome=true ReadWritePaths=/opt/dicemaiden-rs/data PrivateTmp=true [Install] WantedBy=multi-user.target
Multi-process sharding
Each process owns a contiguous shard range and shares one SQLite database.
SHARD_COUNT here is one less than the number of shards the process runs: Serenity 0.12's
start_shard_range treats the end of the range as inclusive, so each process boots shards
SHARD_START through SHARD_START + SHARD_COUNT.
# 3 processes handling 64 shards total SHARD_COUNT=20 SHARD_START=0 TOTAL_SHARDS=64 ./dicemaiden-rs & # shards 0-20 SHARD_COUNT=20 SHARD_START=21 TOTAL_SHARDS=64 ./dicemaiden-rs & # shards 21-41 SHARD_COUNT=21 SHARD_START=42 TOTAL_SHARDS=64 ./dicemaiden-rs & # shards 42-63
Setup, code standards, testing patterns, and the process for adding a new game system are in
CONTRIBUTING.md.
GPLv3
- Open an issue for bugs or feature requests
- Join the Discord for help and discussion
roll_syntax.mdfor dice syntax questions
