diff --git a/assyst-core/src/task/tasks/refresh_entitlements.rs b/assyst-core/src/task/tasks/refresh_entitlements.rs index 3636afb..84e8925 100644 --- a/assyst-core/src/task/tasks/refresh_entitlements.rs +++ b/assyst-core/src/task/tasks/refresh_entitlements.rs @@ -24,9 +24,7 @@ pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) { }, }; - println!("{:?}", additional.iter().map(|x| x.id).collect::>()); - - for a in additional { + for a in additional.clone() { if !assyst.entitlements.lock().unwrap().contains_key(&(a.id.get() as i64)) { let active = match ActiveGuildPremiumEntitlement::try_from(a) { Ok(a) => a, @@ -56,7 +54,10 @@ pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) { // remove entitlements from the db that are not in the rest response for entitlement in db_entitlements.values() { - if !entitlements.contains_key(&entitlement.entitlement_id) { + if !additional + .iter() + .any(|x| x.id.get() as i64 == entitlement.entitlement_id) + { assyst.entitlements.lock().unwrap().remove(&entitlement.entitlement_id); info!( "Removed expired entitlement {} (guild {})", diff --git a/assyst-database/src/model/active_guild_premium_entitlement.rs b/assyst-database/src/model/active_guild_premium_entitlement.rs index 96bc914..fae44b8 100644 --- a/assyst-database/src/model/active_guild_premium_entitlement.rs +++ b/assyst-database/src/model/active_guild_premium_entitlement.rs @@ -7,7 +7,7 @@ use twilight_model::util::Timestamp; use crate::{is_unique_violation, DatabaseHandler}; -#[derive(sqlx::FromRow, Clone)] +#[derive(sqlx::FromRow, Clone, Debug)] pub struct ActiveGuildPremiumEntitlement { pub entitlement_id: i64, pub guild_id: i64,