From b7d36de976ca8a0e2e9724043b1890e6eb4d3e10 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sat, 30 Nov 2024 13:49:30 +0000 Subject: [PATCH] fix: argument names and some logic --- src/commands/minecraft.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/commands/minecraft.rs b/src/commands/minecraft.rs index 7e96b99..5c7772e 100644 --- a/src/commands/minecraft.rs +++ b/src/commands/minecraft.rs @@ -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 { - Ok(_) => {} - Err(e) => { - dbg!("{:?}", e); - return format!("Failure to minecraft UID {:?}", &x.floodgateuid); + 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; } }