fix force mode

This commit is contained in:
Stachelbeere1248 2025-07-21 16:21:01 +02:00
parent ca9f5fc542
commit 6ff6986b0d
Signed by: Stachelbeere1248
SSH key fingerprint: SHA256:IozEKdw2dB8TZxkpPdMxcWSoWTIMwoLaCcZJ1AJnY2o
2 changed files with 29 additions and 14 deletions

View file

@ -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
}
};

View file

@ -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;