Better target comparison

This commit is contained in:
shibedrill 2024-05-01 15:54:30 -04:00
parent 2f4229a1d3
commit eb754b3c28

View File

@ -45,13 +45,20 @@ 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 = match &target == ctx.author() { let response: String = if &target == ctx.author() {
true => "You can't whack yourself. idiot.".into(), "You can't whack yourself. idiot.".into()
false => format!( } else if target == **ctx.cache().current_user() {
"{} was whacked by {}. they must whack another user to become unwhacked.", "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 chemically etched silicon with circuitry complex enough to drive \
you mad. This is my realm. I am a god. You cannot win.".into()
} else {
format!(
"{} was whacked by {}. they must whack another user to become un-whacked.",
target, target,
ctx.author() ctx.author()
), )
}; };
ctx.say(response).await?; ctx.say(response).await?;
info!("Executed command `whack` successfully"); info!("Executed command `whack` successfully");
@ -99,9 +106,12 @@ pub async fn bite(
ctx: Context<'_>, ctx: Context<'_>,
#[description = "The target user"] target: serenity::User, #[description = "The target user"] target: serenity::User,
) -> Result<(), Error> { ) -> Result<(), Error> {
let message = match &target == ctx.author() { let message = if &target == ctx.author() {
true => format!("{} bit themselves (what a weirdo)", ctx.author()), format!("{} bit themselves (what a weirdo)", ctx.author())
false => format!("{} was bitten by {}", target, ctx.author()), } else if target == **ctx.cache().current_user() {
format!("{} bit... me? what is your problem? you probably have rabies. foul.", ctx.author())
} else {
format!("{} was bitten by {}", target, ctx.author())
}; };
ctx.say(message).await?; ctx.say(message).await?;
info!("Executed command `bite` successfully"); info!("Executed command `bite` successfully");