fix: argument names and some logic
This commit is contained in:
parent
68ffa55dc5
commit
b7d36de976
1 changed files with 15 additions and 9 deletions
|
@ -26,14 +26,14 @@ pub(crate) mod user {
|
|||
.description("Link your minecraft account")
|
||||
.create_option(|option| {
|
||||
option
|
||||
.name("Minecraft Username")
|
||||
.name("minecraft_username")
|
||||
.description("Your Minecraft username")
|
||||
.kind(CommandOptionType::String)
|
||||
.required(true)
|
||||
})
|
||||
.create_option(|option| {
|
||||
option
|
||||
.name("Bedrock Account")
|
||||
.name("bedrock_account")
|
||||
.description("Is this a Bedrock account?")
|
||||
.kind(CommandOptionType::Boolean)
|
||||
.required(false)
|
||||
|
@ -80,6 +80,7 @@ pub(crate) mod user {
|
|||
}
|
||||
}
|
||||
|
||||
let username_mc;
|
||||
if java {
|
||||
// insert the username into the database
|
||||
match add_minecraft(&db, &command.user.id, username).await {
|
||||
|
@ -89,25 +90,30 @@ pub(crate) mod user {
|
|||
return format!("Failure to minecraft username {:?}", username);
|
||||
}
|
||||
}
|
||||
username_mc = username.to_string();
|
||||
} else {
|
||||
match get_minecraft_bedrock(username, &config.minecraft_mcprofile).await {
|
||||
None => {
|
||||
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(_) => {}
|
||||
Err(e) => {
|
||||
dbg!("{:?}", e);
|
||||
return format!("Failure to minecraft UID {:?}", &x.floodgateuid);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
username_mc = x.floodgateuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get a list of servers that the user is a member of
|
||||
if let Ok(servers) = get_servers(&db, &command.user.id).await {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue