fix: argument names and some logic
All checks were successful
On_Push / lint_fmt (push) Successful in 6s
On_Push / lint_clippy (push) Successful in 13s
On_Push / build (push) Successful in 1m25s
On_Push / deploy (push) Successful in 12s

This commit is contained in:
silver 2024-11-30 13:49:30 +00:00
parent 68ffa55dc5
commit b7d36de976
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D

View file

@ -26,14 +26,14 @@ pub(crate) mod user {
.description("Link your minecraft account") .description("Link your minecraft account")
.create_option(|option| { .create_option(|option| {
option option
.name("Minecraft Username") .name("minecraft_username")
.description("Your Minecraft username") .description("Your Minecraft username")
.kind(CommandOptionType::String) .kind(CommandOptionType::String)
.required(true) .required(true)
}) })
.create_option(|option| { .create_option(|option| {
option option
.name("Bedrock Account") .name("bedrock_account")
.description("Is this a Bedrock account?") .description("Is this a Bedrock account?")
.kind(CommandOptionType::Boolean) .kind(CommandOptionType::Boolean)
.required(false) .required(false)
@ -80,6 +80,7 @@ pub(crate) mod user {
} }
} }
let username_mc;
if java { if java {
// insert the username into the database // insert the username into the database
match add_minecraft(&db, &command.user.id, username).await { match add_minecraft(&db, &command.user.id, username).await {
@ -89,25 +90,30 @@ pub(crate) mod user {
return format!("Failure to minecraft username {:?}", username); return format!("Failure to minecraft username {:?}", username);
} }
} }
username_mc = username.to_string();
} else { } else {
match get_minecraft_bedrock(username, &config.minecraft_mcprofile).await { match get_minecraft_bedrock(username, &config.minecraft_mcprofile).await {
None => { None => {
return format!("No UID found for {:?}", username); return format!("No UID found for {:?}", username);
} }
Some(x) => match add_minecraft_bedrock(&db, &command.user.id, &x.floodgateuid).await { Some(x) => {
match add_minecraft_bedrock(&db, &command.user.id, &x.floodgateuid).await {
Ok(_) => {} Ok(_) => {}
Err(e) => { Err(e) => {
dbg!("{:?}", e); dbg!("{:?}", e);
return format!("Failure to minecraft UID {:?}", &x.floodgateuid); return format!("Failure to minecraft UID {:?}", &x.floodgateuid);
} }
}, }
username_mc = x.floodgateuid;
}
} }
} }
// get a list of servers that the user is a member of // get a list of servers that the user is a member of
if let Ok(servers) = get_servers(&db, &command.user.id).await { if let Ok(servers) = get_servers(&db, &command.user.id).await {
for server in servers { for server in servers {
whitelist_update(&vec![(username.to_string(), java)], &server.minecraft, &config.discord_token_minecraft).await; whitelist_update(&vec![(username_mc.to_owned(), java)], &server.minecraft, &config.discord_token_minecraft).await;
} }
} }