fix force mode
This commit is contained in:
parent
ca9f5fc542
commit
6ff6986b0d
2 changed files with 29 additions and 14 deletions
|
@ -51,15 +51,27 @@ pub(crate) async fn add(
|
||||||
} else {
|
} else {
|
||||||
Mode::Normal
|
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 {
|
} else {
|
||||||
return Err(Error::Other(
|
Err(Error::Other(
|
||||||
"Force mode cannot be ran without specifying a different Discord account other than \
|
"Force mode cannot be ran without specifying a different Discord account other \
|
||||||
your own."
|
than your own."
|
||||||
.to_string(),
|
.to_string(),
|
||||||
));
|
))
|
||||||
});
|
}
|
||||||
|
} else {
|
||||||
|
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(
|
let uuid: Uuid = Uuid::for_ign(
|
||||||
ign.as_str(),
|
ign.as_str(),
|
||||||
&ctx.data().clients.general,
|
&ctx.data().clients.general,
|
||||||
|
@ -72,13 +84,13 @@ pub(crate) async fn add(
|
||||||
.hypixel_player_data(&ctx.data().clients.hypixel_api_client)
|
.hypixel_player_data(&ctx.data().clients.hypixel_api_client)
|
||||||
.await?
|
.await?
|
||||||
.map_if_discord(user.name.as_str())?;
|
.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)
|
ChannelId::new(1257776992497959075_u64)
|
||||||
.send_message(
|
.send_message(
|
||||||
ctx,
|
ctx,
|
||||||
create_verification_message(
|
create_verification_message(
|
||||||
profile.arcade_stats().copied().unwrap_or_default(),
|
profile.arcade_stats().copied().unwrap_or_default(),
|
||||||
&user,
|
user,
|
||||||
ign,
|
ign,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -89,13 +101,13 @@ pub(crate) async fn add(
|
||||||
let profile = uuid
|
let profile = uuid
|
||||||
.hypixel_player_data(&ctx.data().clients.hypixel_api_client)
|
.hypixel_player_data(&ctx.data().clients.hypixel_api_client)
|
||||||
.await?;
|
.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)
|
ChannelId::new(1257776992497959075_u64)
|
||||||
.send_message(
|
.send_message(
|
||||||
ctx,
|
ctx,
|
||||||
create_verification_message(
|
create_verification_message(
|
||||||
profile.arcade_stats().copied().unwrap_or_default(),
|
profile.arcade_stats().copied().unwrap_or_default(),
|
||||||
&user,
|
user,
|
||||||
ign,
|
ign,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -103,7 +115,7 @@ pub(crate) async fn add(
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
Mode::NoApi => {
|
Mode::NoApi => {
|
||||||
let done = link(&ctx.data().sqlite_pool, uuid, &user).await?;
|
let done = link(&ctx.data().sqlite_pool, uuid, user).await?;
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use poise::{CreateReply, FrameworkError};
|
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;
|
use crate::Data;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue