#Check if a User has Premium.
1 messages · Page 1 of 1 (latest)
Discord bot SKUs
and/or entitlements
My issue is that, if people subscribed before I added SKU entitlement handling how can I know if a user has premium?
You can check Context.Interaction.Entitlements
Something like
public static bool IsPremium(IReadOnlyCollection<RestEntitlement> entitlements)
{
return entitlements.Count > 0 && entitlements.FirstOrDefault(x => x.SkuId == 1156298921421852733) is not null;
}```
should work
(Obviously adjust to whatever sku numbers you are looking for)
I primarily use the Entitlement event handling to monitor and store new subscriptions in the DB, but I also have this as a fallback for if that ever fails or such
I'm unsure if you are able to see a user's entitlements to other bots, if you can only see entitlements to your own bot, then the specific ID check is probably not required (unless you have multiple skus, like user vs server premium or such, plus I think discord plans to allow multiple tiers at some point, so depends on your use case)
Thanks a bunch!
Np 🙂
is there anyway to then get the SocketEntitlement?
so that I can update my DB?
Why? what information would you need that isn't just included in the rest entity?
Also not that im aware of