Skip to content

Commit

Permalink
feat: remove htm from db if user doesn't have htm at time of leaving (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanish2002 authored Aug 25, 2024
1 parent 2d77f8c commit 9ce2ba6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/robbb/src/events/guild_member_removal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ pub async fn guild_member_removal(

if let Some(member) = member {
let roles = member.roles(&ctx).unwrap_or_default();
if roles.iter().any(|x| x.id == config.role_htm) {
let is_htm = db.check_user_htm(member.user.id).await?; // check if already htm is added to DB

if roles.iter().any(|x| x.id == config.role_htm) && !is_htm {
// add htm if not in db already
log_error!(db.add_htm(member.user.id).await);
} else {
// remove htm from db if user doesn't have htm anymore
log_error!(db.remove_htm(member.user.id).await);
}
}

Expand Down

0 comments on commit 9ce2ba6

Please sign in to comment.