diff --git a/src/command/fun.rs b/src/command/fun.rs index 88a36ff..9997b86 100644 --- a/src/command/fun.rs +++ b/src/command/fun.rs @@ -50,3 +50,38 @@ pub async fn penis( } Ok(()) } + +/// Magic 8-ball +#[poise::command(slash_command)] +pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> { + let responses = [ + "It is certain", + "It is decidedly so", + "Without a doubt", + "Yes definitely", + "You may rely on it", + "As I see it, yes", + "Most likely", + "Outlook good", + "Yes", + "Signs point to yes", + "Reply hazy, try again", + "Ask again later", + "Better not to tell you now", + "Cannot predict now", + "Concentrate and ask again", + "Don't count on it", + "My reply is no", + "My sources say no", + "Outlook not so good", + "Very doubtful", + ]; + let response = { + let mut rng = rand::thread_rng(); + responses.choose(&mut rng).unwrap() + }; + ctx.say(format!("Magic 8-ball says: '{}'", *response)) + .await?; + info!("Executed command `eightball` successfully"); + Ok(()) +} diff --git a/src/command/util.rs b/src/command/util.rs index 2eac00c..5af18b3 100644 --- a/src/command/util.rs +++ b/src/command/util.rs @@ -1,4 +1,5 @@ use poise::serenity_prelude as serenity; +use rand::Rng; use crate::Context; use crate::Error; @@ -43,7 +44,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> { Ok(()) } -/// Add information to the shared settings +/// Add channel to the registry #[poise::command(slash_command)] pub async fn add_channel( ctx: Context<'_>, @@ -68,7 +69,7 @@ pub async fn add_channel( Ok(()) } -/// Remove information from the shared settings +/// Remove channel from the registry #[poise::command(slash_command)] pub async fn remove_channel( ctx: Context<'_>, @@ -94,6 +95,7 @@ pub async fn remove_channel( Ok(()) } +/// List channels held in the registry #[poise::command(slash_command)] pub async fn list_channels(ctx: Context<'_>) -> Result<(), Error> { ctx.defer_ephemeral().await?; @@ -111,3 +113,22 @@ pub async fn list_channels(ctx: Context<'_>) -> Result<(), Error> { info!("Executed command `list_channels` successfully"); Ok(()) } + +/// Generate a random number, supply 1 for coin toss +#[poise::command(slash_command)] +pub async fn dice( + ctx: Context<'_>, + #[description = "The upper limit of the random number"] bound: u32, +) -> Result<(), Error> { + let answer: u32 = { + let mut rng = rand::thread_rng(); + rng.gen_range(0..=bound) + }; + ctx.say(format!( + "Rolled a random number from 0 to {}, got: {}", + bound, answer + )) + .await?; + info!("Executed command `dice` successfully"); + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 844c80f..bdf5979 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,12 +84,14 @@ async fn main() { remove_channel(), list_channels(), invite(), + dice(), // Dev shutdown(), restart(), // Fun meow(), penis(), + eightball(), ], initialize_owners: true, ..Default::default()