Documentation for each slash command pops up in Discord when you type /
in a message box.
A simple dice roller. Here are some examples:
/roll
(defaults to 1d20) returns: "@user
rolled 10."/roll sides: 20
returns: "@user
rolled 13."/roll sides: 6 rolls: 2
returns: "@user
rolled 2, 5."
NOTE: This functionality is currently disabled. YouTube is not happy with my usage of yt-dlp... 👀
Plays a user's introduction sound when they join a voice channel. This is configurable with the following commands:
/set_intro
- Add an introduction sound from a YouTube URL/clear_intro
- Remove your introduction sound
- Sounds are set on a per-guild basis.
- The YouTube video length can be up to 5 seconds long.
- The bot joins the voice channel (if not already present) to play the introduction sound.
- The bot will stick around so that subsequent user joins can be announced faster.
- The bot leaves the voice channel after 5 minutes of inactivity.
The previous incarnation of this bot used a serverless API and Discord Interactions to handle the /roll
slash command without a Discord framework. I was pretty proud of that, but I wanted to add more features and learn more about Rust, so I decided to rewrite it.
What I'm using:
- 🦀 Rust ✨
- 🎙️ Serenity, Poise, and Songbird for the Discord client
- 🐘 PostgreSQL and
sqlx
for persistence - 🪄 GitHub Actions for CI/CD
Future improvements:
- cache audio for faster playback
- help command
- instrument with tracing spans
- replace hard-coded values with configuration
FIXME: No longer using dev container. Re-write this section for Nix or add back a dev container that uses Nix.
You can get this running locally easily using Dev Containers. This assumes you have Docker and Visual Studio Code installed, including the Remote Containers extension.
To set up the development environment:
- Open Visual Studio Code
- From the command palette, select "Dev Containers: Clone Repository in Container Volume..."
- Enter
fng97/adventus
Now just wait for the container to build before Visual Studio Code reloads with your development environment ready to go!
To run the tests:
- Start the database:
./scripts/init_db.sh
- Run the tests:
cargo test
To run the bot:
- Ensure
Secrets.toml
includes your discord token in the formatDISCORD_TOKEN="your_token_here"
- Start the database if you haven't already:
./scripts/init_db.sh
- Run the bot locally:
cargo shuttle run