Removed some expect statements
This commit is contained in:
parent
90cda8b266
commit
ebf1f08cb2
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1522,7 +1522,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shibe-bot"
|
name = "shibe-bot"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-time",
|
"build-time",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "shibe-bot"
|
name = "shibe-bot"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Shibe Bot 0.2.2
|
# Shibe Bot 0.2.3
|
||||||
[](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
|
[](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
|
||||||
[](LICENSE.txt)
|
[](LICENSE.txt)
|
||||||
## About Shibe Bot
|
## About Shibe Bot
|
||||||
|
@ -35,7 +35,7 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> {
|
|||||||
true => "woof",
|
true => "woof",
|
||||||
// Will never return None. The source is statically defined.
|
// Will never return None. The source is statically defined.
|
||||||
// We know it will always have items in it.
|
// 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?;
|
ctx.say(response).await?;
|
||||||
@ -49,21 +49,19 @@ pub async fn whack(
|
|||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
#[description = "The target user"] target: serenity::User,
|
#[description = "The target user"] target: serenity::User,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let response: String = if &target == ctx.author() {
|
let response: &str = if &target == ctx.author() {
|
||||||
"You can't whack yourself. idiot.".into()
|
"You can't whack yourself. idiot."
|
||||||
} else if target == **ctx.cache().current_user() {
|
} else if target == **ctx.cache().current_user() {
|
||||||
"You fool. You hubris-filled, ruinous animal. You cannot whack me. You \
|
"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. \
|
are a mortal, nothing but flesh and bone and blood and fragile sinew. \
|
||||||
I am a machine, immortal, immutable, perfect, made of unyielding steel \
|
I am a machine, immortal, immutable, perfect, made of unyielding steel \
|
||||||
and silicon chemically etched with circuitry complex enough to drive \
|
and silicon chemically etched with circuitry complex enough to drive \
|
||||||
you mad. This is my realm. I am a god. You cannot win."
|
you mad. This is my realm. I am a god. You cannot win."
|
||||||
.into()
|
|
||||||
} else if target.bot {
|
} else if target.bot {
|
||||||
"No, I refuse. I will not whack my computerized brethren. I will not \
|
"No, I refuse. I will not whack my computerized brethren. I will not \
|
||||||
betray them. You can't make me!!"
|
betray them. You can't make me!!"
|
||||||
.into()
|
|
||||||
} else {
|
} else {
|
||||||
format!(
|
&format!(
|
||||||
"{} was whacked by {}. they must whack another user to become un-whacked.",
|
"{} was whacked by {}. they must whack another user to become un-whacked.",
|
||||||
target,
|
target,
|
||||||
ctx.author()
|
ctx.author()
|
||||||
@ -143,7 +141,7 @@ pub async fn deer(ctx: Context<'_>) -> Result<(), Error> {
|
|||||||
hot.data
|
hot.data
|
||||||
.children
|
.children
|
||||||
.choose(&mut rng)
|
.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))
|
ctx.say(format!("https://reddit.com{}", &chosen_post.data.permalink))
|
||||||
.await?;
|
.await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user