beebot/src/commands/fun/roll.rs
2025-08-31 17:13:18 +02:00

16 lines
454 B
Rust

use crate::{Context, Error};
use rand::prelude::*;
/// Will throw a dice of x faces
#[poise::command(slash_command, prefix_command)]
pub async fn roll(
ctx: Context<'_>,
#[description = "Le nombre de faces du dé"] faces: u64,
) -> Result<(), Error> {
let num = (1..faces).choose(&mut rand::rng()).unwrap_or(1);
let response = format!("Le dé à {} faces est tombé sur **{}**", faces, num);
ctx.say(response).await?;
Ok(())
}