From 5b22f699d687fd41880c91a10938123fafccf85a Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sat, 9 Nov 2024 14:59:05 +0000 Subject: [PATCH] fix: getting teh server config needs to happen after checking for committee --- src/main.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index be4eebb..62c0350 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,10 +31,6 @@ impl EventHandler for Handler { }; let db = db_lock.read().await; - let config = match get_server_config(&db, &new_member.guild_id).await { - None => return, - Some(x) => x, - }; let config_lock = { let data_read = ctx.data.read().await; @@ -49,17 +45,22 @@ impl EventHandler for Handler { return; } + let config_server = match get_server_config(&db, &new_member.guild_id).await { + None => return, + Some(x) => x, + }; + if get_server_member(&db, &new_member.guild_id, &new_member).await.is_ok() { let mut roles = vec![]; - if let Some(role) = &config.role_past { + if let Some(role) = &config_server.role_past { if !new_member.roles.contains(role) { roles.push(role.to_owned()); } } - if !new_member.roles.contains(&config.role_current) { - roles.push(config.role_current.to_owned()); + if !new_member.roles.contains(&config_server.role_current) { + roles.push(config_server.role_current.to_owned()); } if let Err(e) = new_member.add_roles(&ctx, &roles).await { @@ -72,10 +73,10 @@ Welcome {} to the {} server! Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use ``/link_wolves`` to get full access. "#, new_member.display_name(), - &config.server_name, - &config.wolves_link, - &config.server, - &config.bot_channel_id + &config_server.server_name, + &config_server.wolves_link, + &config_server.server, + &config_server.bot_channel_id ); if let Err(err) = new_member.user.direct_message(&ctx, |m| m.content(&msg)).await {