Skip to content

Commit

Permalink
fix fetching premium
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacherr committed Oct 21, 2024
1 parent 33a8861 commit 0538586
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions assyst-core/src/command/misc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub async fn patronstatus(ctxt: CommandCtxt<'_>) -> anyhow::Result<()> {

let l = ctxt.assyst().entitlements.lock().unwrap().clone();
let entitlement_status = if let Some(g) = ctxt.data.guild_id {
let entitlement = l.get(&(g.get() as i64));
let entitlement = l.iter().find(|(_, ent)| ent.guild_id as u64 == g).map(|x| x.1);
match entitlement {
Some(e) => Some(Some(e)),
None => Some(None),
Expand All @@ -216,8 +216,9 @@ pub async fn patronstatus(ctxt: CommandCtxt<'_>) -> anyhow::Result<()> {
match entitlement_status {
Some(Some(e)) => format!("This server is an activated premium server. It was activated by <@{0}> ({0}).", e.user_id),
Some(None) => format!(
"This server is not activated a premium server. You can activate it [here](https://discord.com/application-directory/571661221854707713/store/{}).",
CONFIG.entitlements.premium_server_sku_id
"This server is not activated a premium server. You can activate it [here](<https://discord.com/application-directory/{}/store/{}>).",
CONFIG.bot_id,
CONFIG.entitlements.premium_server_sku_id,
),
None => "This is not a server, so it cannot have premium server benefits.".to_owned()
},
Expand Down
2 changes: 0 additions & 2 deletions assyst-core/src/task/tasks/refresh_entitlements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use tracing::info;
use crate::assyst::ThreadSafeAssyst;

pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) {
let entitlements = assyst.entitlements.lock().unwrap().clone();

let additional = match assyst.http_client.entitlements(assyst.application_id).await {
Ok(x) => match x.model().await {
Ok(e) => e,
Expand Down
7 changes: 6 additions & 1 deletion assyst-flux-iface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ impl FluxHandler {
}

if let Some(guild_id) = guild_id
&& self.premium_guilds.lock().unwrap().get(&(guild_id as i64)).is_some()
&& self
.premium_guilds
.lock()
.unwrap()
.iter()
.any(|(_, ent)| ent.guild_id as u64 == guild_id)
{
return Ok(LIMITS_GUILD_TIER_1);
}
Expand Down

0 comments on commit 0538586

Please sign in to comment.