diff --git a/assyst-core/src/main.rs b/assyst-core/src/main.rs index e0b36fe..ec6d72b 100644 --- a/assyst-core/src/main.rs +++ b/assyst-core/src/main.rs @@ -238,7 +238,7 @@ async fn main() { }); info!("Caching web download API URLs"); - let web_download_urls = get_web_download_api_urls(&a.reqwest_client).await.unwrap(); + let web_download_urls = get_web_download_api_urls(&a.reqwest_client).await.unwrap_or(vec![]); info!("Got {} URLs to cache", web_download_urls.len()); debug!(?web_download_urls); a.rest_cache_handler.set_web_download_urls(web_download_urls); diff --git a/assyst-core/src/task/tasks/refresh_entitlements.rs b/assyst-core/src/task/tasks/refresh_entitlements.rs index e7a4785..45426c5 100644 --- a/assyst-core/src/task/tasks/refresh_entitlements.rs +++ b/assyst-core/src/task/tasks/refresh_entitlements.rs @@ -1,8 +1,7 @@ use assyst_common::err; +use assyst_common::macros::handle_log; use assyst_database::model::active_guild_premium_entitlement::ActiveGuildPremiumEntitlement; use tracing::info; -use twilight_model::id::marker::EntitlementMarker; -use twilight_model::id::Id; use crate::assyst::ThreadSafeAssyst; @@ -10,29 +9,18 @@ pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) { let clone = assyst.entitlements.lock().unwrap().clone(); let mut entitlements = clone.iter().collect::>(); entitlements.sort_by(|x, y| y.1.entitlement_id.cmp(&x.1.entitlement_id)); - let latest = entitlements.first(); - let additional = match latest { - Some(l) => { - match assyst - .http_client - .entitlements(assyst.application_id) - .after(Id::::new(l.1.entitlement_id as u64)) - .await - { - Ok(x) => match x.model().await { - Ok(e) => e, - Err(e) => { - err!("Failed to get potential new entitlements: {e:?}"); - vec![] - }, - }, - Err(e) => { - err!("Failed to get potential new entitlements: {e:?}"); - vec![] - }, - } + let additional = match assyst.http_client.entitlements(assyst.application_id).await { + Ok(x) => match x.model().await { + Ok(e) => e, + Err(e) => { + err!("Failed to get potential new entitlements: {e:?}"); + vec![] + }, + }, + Err(e) => { + err!("Failed to get potential new entitlements: {e:?}"); + vec![] }, - None => vec![], }; for a in additional { @@ -51,6 +39,7 @@ pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) { active.entitlement_id ); }; + handle_log(format!("New entitlement! Guild: {}", active.guild_id)); assyst.entitlements.lock().unwrap().insert(active.guild_id, active); } }