Skip to content

fng97/adventus

Repository files navigation

Adventus

👋 Add me to your server!

Features

Documentation for each slash command pops up in Discord when you type / in a message box.

🎲 Roller

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

📯 Introductions

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

Notes

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

How does it work?

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:

Future improvements:

  • cache audio for faster playback
  • help command
  • instrument with tracing spans
  • replace hard-coded values with configuration

Running Locally

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:

  1. Open Visual Studio Code
  2. From the command palette, select "Dev Containers: Clone Repository in Container Volume..."
  3. 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:

  1. Start the database: ./scripts/init_db.sh
  2. Run the tests: cargo test

To run the bot:

  1. Ensure Secrets.toml includes your discord token in the format DISCORD_TOKEN="your_token_here"
  2. Start the database if you haven't already: ./scripts/init_db.sh
  3. Run the bot locally: cargo shuttle run