From 137f01a9b2b11a7849a45486af801c8c0b802113 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Mon, 19 Dec 2022 19:45:31 -0700 Subject: [PATCH] Added audit command + bad bot reacion + clippy + fmt --- src/discord/fren_coin.rs | 18 +++++++++++++++--- src/discord/mod.rs | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/discord/fren_coin.rs b/src/discord/fren_coin.rs index febb12f..346bd77 100644 --- a/src/discord/fren_coin.rs +++ b/src/discord/fren_coin.rs @@ -26,16 +26,28 @@ pub fn get_user_wallet(cfg: &mut BotConfig, discord_id: UserId) -> &mut Wallet { #[command] #[description("Get your current balance")] +#[aliases("audit")] #[only_in(guilds)] -async fn balance(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { +async fn balance(ctx: &Context, msg: &Message, args: Args) -> CommandResult { let mut data = ctx.data.write().await; let global_data = data.get_mut::().unwrap(); - let wallet = get_user_wallet(&mut global_data.cfg, msg.author.id); + let user = args.parse::().unwrap_or(msg.author.id); + + let wallet = get_user_wallet(&mut global_data.cfg, user); msg.reply( &ctx.http, - format!("Your current balance is {} fren coins!", wallet.coin_count), + format!( + "{}'s current balance is {} fren coins!", + msg.guild(&ctx.cache) + .unwrap() + .member(&ctx.http, user) + .await + .unwrap() + .mention(), + wallet.coin_count + ), ) .await?; diff --git a/src/discord/mod.rs b/src/discord/mod.rs index 303b1f1..26c67e0 100644 --- a/src/discord/mod.rs +++ b/src/discord/mod.rs @@ -98,6 +98,10 @@ impl EventHandler for Handler { } } + if new_message.content.to_lowercase().contains("bad bot") { + new_message.react(&ctx.http, '😭').await.unwrap(); + } + give_coin(&ctx, new_message.author.id, 0.05, 5) .await .unwrap();