silly goober bot

feat: roll command (#2)

Co-authored-by: Isabel <isabel@isabelroses.com>

authored by

robin isabelroses.com and committed by isabelroses.com f2783587 15fe57da

+19
+1
Cargo.lock
··· 120 120 "dotenv", 121 121 "humantime", 122 122 "poise", 123 + "rand", 123 124 "regex", 124 125 "reqwest 0.12.4", 125 126 "serenity",
+1
Cargo.toml
··· 15 15 dotenv = "0.15.0" 16 16 humantime = "2.1.0" 17 17 poise = "0.6.1" 18 + rand = "0.8.5" 18 19 regex = "1.10.5" 19 20 reqwest = "0.12.4" 20 21 serenity = "0.12.2"
+15
src/commands/dice.rs
··· 1 + use crate::Context; 2 + use color_eyre::eyre::Result; 3 + use rand::Rng; 4 + 5 + /// Rolls dice based on given # of sides 6 + #[poise::command(slash_command)] 7 + pub async fn roll( 8 + ctx: Context<'_>, 9 + #[description = "# of sides"] sides: Option<u32>, 10 + ) -> Result<()> { 11 + let sides = sides.unwrap_or(6); 12 + let roll = rand::thread_rng().gen_range(1..=sides); 13 + ctx.say(format!("You rolled a **{}**", roll)).await?; 14 + Ok(()) 15 + }
+1
src/commands/mod.rs
··· 2 2 pub mod kittysay; 3 3 pub mod ping; 4 4 pub mod user; 5 + pub mod dice;
+1
src/main.rs
··· 31 31 commands::user::whois::whois(), 32 32 commands::user::avatar::avatar(), 33 33 commands::kittysay::kittysay(), 34 + commands::dice::roll(), 34 35 ], 35 36 event_handler: |ctx, event, _, data| { 36 37 Box::pin(async move {