fix: getting teh server config needs to happen after checking for committee

This commit is contained in:
silver 2024-11-09 14:59:05 +00:00
parent 6739c7e068
commit 5b22f699d6
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D

View file

@ -31,10 +31,6 @@ impl EventHandler for Handler {
}; };
let db = db_lock.read().await; 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 config_lock = {
let data_read = ctx.data.read().await; let data_read = ctx.data.read().await;
@ -49,17 +45,22 @@ impl EventHandler for Handler {
return; 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() { if get_server_member(&db, &new_member.guild_id, &new_member).await.is_ok() {
let mut roles = vec![]; 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) { if !new_member.roles.contains(role) {
roles.push(role.to_owned()); roles.push(role.to_owned());
} }
} }
if !new_member.roles.contains(&config.role_current) { if !new_member.roles.contains(&config_server.role_current) {
roles.push(config.role_current.to_owned()); roles.push(config_server.role_current.to_owned());
} }
if let Err(e) = new_member.add_roles(&ctx, &roles).await { 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. Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use ``/link_wolves`` to get full access.
"#, "#,
new_member.display_name(), new_member.display_name(),
&config.server_name, &config_server.server_name,
&config.wolves_link, &config_server.wolves_link,
&config.server, &config_server.server,
&config.bot_channel_id &config_server.bot_channel_id
); );
if let Err(err) = new_member.user.direct_message(&ctx, |m| m.content(&msg)).await { if let Err(err) = new_member.user.direct_message(&ctx, |m| m.content(&msg)).await {