diff --git a/src/commands/accountv2.rs b/src/commands/accountv2.rs index 005dcde..23c5c89 100644 --- a/src/commands/accountv2.rs +++ b/src/commands/accountv2.rs @@ -51,15 +51,27 @@ pub(crate) async fn add( } else { Mode::Normal }; - let user: User = target.unwrap_or(if mode == Mode::Normal { - ctx.author().clone() + + let user = if let Some(u) = target.as_ref() { + if !u.eq(ctx.author()) { + Ok(u) + } else { + Err(Error::Other( + "Force mode cannot be ran without specifying a different Discord account other \ + than your own." + .to_string(), + )) + } } else { - return Err(Error::Other( - "Force mode cannot be ran without specifying a different Discord account other than \ - your own." - .to_string(), - )); - }); + if mode != Mode::Normal { + Err(Error::Other( + "Force mode cannot be ran without specifying a target." + .to_string(), + )) + } else { + Ok(ctx.author()) + } + }?; let uuid: Uuid = Uuid::for_ign( ign.as_str(), &ctx.data().clients.general, @@ -72,13 +84,13 @@ pub(crate) async fn add( .hypixel_player_data(&ctx.data().clients.hypixel_api_client) .await? .map_if_discord(user.name.as_str())?; - let done = link(&ctx.data().sqlite_pool, uuid, &user).await?; + let done = link(&ctx.data().sqlite_pool, uuid, user).await?; ChannelId::new(1257776992497959075_u64) .send_message( ctx, create_verification_message( profile.arcade_stats().copied().unwrap_or_default(), - &user, + user, ign, ), ) @@ -89,13 +101,13 @@ pub(crate) async fn add( let profile = uuid .hypixel_player_data(&ctx.data().clients.hypixel_api_client) .await?; - let done = link(&ctx.data().sqlite_pool, uuid, &user).await?; + let done = link(&ctx.data().sqlite_pool, uuid, user).await?; ChannelId::new(1257776992497959075_u64) .send_message( ctx, create_verification_message( profile.arcade_stats().copied().unwrap_or_default(), - &user, + user, ign, ), ) @@ -103,7 +115,7 @@ pub(crate) async fn add( done } Mode::NoApi => { - let done = link(&ctx.data().sqlite_pool, uuid, &user).await?; + let done = link(&ctx.data().sqlite_pool, uuid, user).await?; done } }; diff --git a/src/error.rs b/src/error.rs index 4560608..80d6ca4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,8 @@ use poise::{CreateReply, FrameworkError}; -use std::{fmt::{Display, Formatter, Result as FmtResult}, num::ParseIntError}; +use std::{ + fmt::{Display, Formatter, Result as FmtResult}, + num::ParseIntError, +}; use crate::Data;