From bbca2187088d660344dabf6c5988f3a1fe9cb91f Mon Sep 17 00:00:00 2001 From: shibedrill <53824200+shibedrill@users.noreply.github.com> Date: Thu, 16 May 2024 17:22:29 -0400 Subject: [PATCH] minor fixes --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/command/fun.rs | 12 ++++++++---- src/command/util.rs | 8 ++++---- src/main.rs | 8 ++++---- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 658d4df..50e29a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "shibe-bot" -version = "0.2.0" +version = "0.2.1" dependencies = [ "dotenv", "log", diff --git a/Cargo.toml b/Cargo.toml index 392f5d3..ab9673f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shibe-bot" -version = "0.2.0" +version = "0.2.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/command/fun.rs b/src/command/fun.rs index 0d78be7..6fae33b 100644 --- a/src/command/fun.rs +++ b/src/command/fun.rs @@ -24,14 +24,18 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> { "IM GONNA MROWWWWW!!11!11!", "meow meow bitchass", "mrrghh???", + "meow meow meow meow meow", + "mrow,,,,,", + "meow??", + "bwrrrr,,,", ]; let response = { let mut rng = rand::thread_rng(); match rng.gen_bool(0.05) { true => "woof", - // Will never return None. The source is staticaly defined. + // Will never return None. The source is statically defined. // We know it will always have items in it. - false => meows.choose(&mut rng).unwrap(), + false => meows.choose(&mut rng).expect("`meows` array is empty"), } }; ctx.say(response).await?; @@ -92,7 +96,7 @@ pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> { ]; let response = { let mut rng = rand::thread_rng(); - responses.choose(&mut rng).unwrap() + responses.choose(&mut rng).expect("`responses` array is empty") }; ctx.say(format!("Magic 8-ball says: '{}'", *response)) .await?; @@ -126,7 +130,7 @@ pub async fn deer(ctx: Context<'_>) -> Result<(), Error> { let hot = subreddit.hot(50, Some(options)).await?; let chosen_post = { let mut rng = rand::thread_rng(); - hot.data.children.choose(&mut rng).unwrap() + hot.data.children.choose(&mut rng).expect("Hot posts does not have any items") }; ctx.say(format!("https://reddit.com{}", &chosen_post.data.permalink)) .await?; diff --git a/src/command/util.rs b/src/command/util.rs index b43b9cb..e589696 100644 --- a/src/command/util.rs +++ b/src/command/util.rs @@ -39,8 +39,8 @@ pub async fn age( pub async fn info(ctx: Context<'_>) -> Result<(), Error> { ctx.say(format!( "Shibe Bot v{} was created by Shibe Drill (@shibedrill) using Rust and \ - Poise.\nVisit her website: \nCheck out her \ - Github: \n\ + Poise.\nWebsite: \n\ + Source code: \n\ Poise: \n\ Rust: ", env!("CARGO_PKG_VERSION") @@ -59,7 +59,7 @@ pub async fn add_channel( let config = &mut ctx.data().config_manager.lock().await; let channel_id = { u64::from(channel.id()) }; config.channels.push(channel); - config.store().unwrap(); + config.store().expect("Unable to store config"); ctx.say(format!( "Successfully added <#{}> to the channel registry.", channel_id @@ -79,7 +79,7 @@ pub async fn remove_channel( let config = &mut ctx.data().config_manager.lock().await; let channel_id = { u64::from(channel.id()) }; config.channels.retain(|c| c.id() != channel.id()); - config.store().unwrap(); + config.store().expect("Unable to store config"); ctx.say(format!( "Successfully removed <#{}> from the channel registry.", channel_id diff --git a/src/main.rs b/src/main.rs index eccaf01..7ca6dc1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -125,7 +125,7 @@ async fn main() { let mut client = serenity::ClientBuilder::new(token, intents) .framework(framework) .await - .unwrap(); + .expect("Unable to build client"); info!("Built client successfully"); // List the owner @@ -135,14 +135,14 @@ async fn main() { .http .get_current_application_info() .await - .unwrap() + .expect("Could not get current application info") .owner - .unwrap() + .expect("Could not get owner info") .name ); // Finally start everything. Nothing after this should be reachable normally. info!("Starting client"); - client.start().await.unwrap(); + client.start().await.expect("Could not start client"); info!("All tasks finished, shutting down"); }