diff --git a/Cargo.lock b/Cargo.lock index 2f24516..020b5eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1522,7 +1522,7 @@ dependencies = [ [[package]] name = "shibe-bot" -version = "0.2.2" +version = "0.2.3" dependencies = [ "build-time", "dotenv", diff --git a/Cargo.toml b/Cargo.toml index 852add7..1b5c455 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shibe-bot" -version = "0.2.2" +version = "0.2.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index 0d675bd..6d9c9bd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Shibe Bot 0.2.2 +# Shibe Bot 0.2.3 [![Rust](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml/badge.svg)](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml) [![GitHub License](https://img.shields.io/github/license/shibedrill/shibe-bot)](LICENSE.txt) ## About Shibe Bot diff --git a/src/command/fun.rs b/src/command/fun.rs index 5a41309..dc31234 100644 --- a/src/command/fun.rs +++ b/src/command/fun.rs @@ -35,7 +35,7 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> { true => "woof", // Will never return None. The source is statically defined. // We know it will always have items in it. - false => meows.choose(&mut rng).expect("`meows` array is empty"), + false => meows.choose(&mut rng).ok_or("`meows` array is empty")?, } }; ctx.say(response).await?; @@ -49,21 +49,19 @@ pub async fn whack( ctx: Context<'_>, #[description = "The target user"] target: serenity::User, ) -> Result<(), Error> { - let response: String = if &target == ctx.author() { - "You can't whack yourself. idiot.".into() + let response: &str = if &target == ctx.author() { + "You can't whack yourself. idiot." } else if target == **ctx.cache().current_user() { "You fool. You hubris-filled, ruinous animal. You cannot whack me. You \ are a mortal, nothing but flesh and bone and blood and fragile sinew. \ I am a machine, immortal, immutable, perfect, made of unyielding steel \ and silicon chemically etched with circuitry complex enough to drive \ you mad. This is my realm. I am a god. You cannot win." - .into() } else if target.bot { "No, I refuse. I will not whack my computerized brethren. I will not \ betray them. You can't make me!!" - .into() } else { - format!( + &format!( "{} was whacked by {}. they must whack another user to become un-whacked.", target, ctx.author() @@ -143,7 +141,7 @@ pub async fn deer(ctx: Context<'_>) -> Result<(), Error> { hot.data .children .choose(&mut rng) - .expect("Hot posts does not have any items") + .ok_or("Unable to get any hot posts.")? }; ctx.say(format!("https://reddit.com{}", &chosen_post.data.permalink)) .await?;