#Handling Durables
1 messages · Page 1 of 1 (latest)
ENTITLEMENT_CREATE <=> EntitlementCreated
LIST Entitlements <=> GetEntitlementsAsync
Interaction Payloads <=> IDiscordInteraction.Entitlements
oh, so I should make sure to save durable
it depends™️
if you only gonna check for it on command uses - there's no real need, since we have IDiscordInteraction.Entitlements
so like if I had a lifetime premium durable, it is still sent in the entitlements?
yah
basically you get all entitlements applicable to that interaction context (guild/user subsriptions, one time purchasables )
ok that is what I thought originally, but somehow I have user who bought lifetime and cannot use commands, but in the logs from this method:
public static bool IsPremium(IReadOnlyCollection<RestEntitlement> entitlements)
{
if (entitlements == null) return false;
Console.WriteLine("Entitlements:");
foreach (var entitlement in entitlements)
{
Console.WriteLine(entitlement.SkuId);
}
return entitlements.Any(x => x.SkuId == 1169107771673812992 || x.SkuId == 1282452500913328180);
}
they have none

uh
well
that's interesting.
That's the second case of this happening as i remember
oh dear
what is the temp solution?
rest calls
doing a GetwhateverAsync for that user
but yah
I can't confirm whether this is a bug or not
should I be concerned about ratelimiting from that?
if there's a non-async method on the socket client - then I did
ah ok
so you can call the rest call once & it should cache iirc
not sure though
so uh
if you will
- Is the sku:
- one time purchase?
- is it durable?
- whats one's id?
- app id
- screenshot of debug view of interaction.Entitlements collection
- ............ of result of a
GetEntitlementsAsync=>userId: idOfTheUser
with that I can at least ask & maybe report if it's actually a bug
-# unfortunately most of @fickle hazel premium users don't use discord's subscriptions so yah
I couldn't reproduce this with test entitlements so i'm not sure what casues this exactly
- Is the sku:
- one time purchase? yes
- is it durable? yes
- whats one's id? 1282452500913328180
- app id 705680059809398804
- screenshot of debug view of interaction.Entitlements collection :( I dont wanna reinstall visual studios lmao
- ............ of result of a
GetEntitlementsAsyncwait what does this do?
GetEntitlementsAsync
literally just does a rest GET request
DiscordSocketClient.GetEntitlementsAsync(userId: 691337) would get entitlements for a given user
This looks correct and is basically the same as how we implemented it in Cakey (though we use IEntitlement instead of RestEntitlement). Your saying this method is returning null for you though?
What code are you using to pass the entitlements to this method?
within a slash command like this:
IsPremium(Context.Interaction.Entitlements)
yeah that should work
and it's showing as null on your production bot right? Keep in mind your beta/testing/dev bot wont have any entitlements for the user (as they are separate from the prod bot)
so, on my prod bot my user who verifiably bought lifetime premium is shown as having no entitlements, the object is not null, there just are no entitlements for the user. When I use a command which calls that method (I have the monthly subscription) it is properly listed.
are you on the latest DNet version?
should not matter
I am though
I haven't touched that code since the initial release/discord's breakings
Durables were added later after subscriptions iirc so early versions may not list durable skus?
but if hes on latest wouldnt matter anyways
why can I not grant myself an sku wtf lol
out of wild curiosity (it definitely shouldn't make a difference), but, if you change RestEntitlement to IEntitlement in your IsPremium method does it change anything? lol
I might be dumb, but does this do what I want?
public async Task GetEntitlements()
{
StringBuilder response = new();
await foreach (var entitlementCollection in Bot.Client.GetEntitlementsAsync())
{
foreach (var entitlement in entitlementCollection)
{
response.AppendLine(entitlement.SkuId.ToString());
Console.WriteLine(entitlement.SkuId);
}
}
await RespondAsync(text: response.ToString());
}
it got an odd result:
1282452500913328180
1282452500913328180
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
1169107771673812992
Well that would get all entitlements for your bot
var data = await discord.Rest.GetEntitlementsAsync(excludeEnded: true).FlattenAsync();
int count = 0;
var results = data.Aggregate("", (current, et) => current + $"[{count++}] ID: {et.Id} - Type: {et.Type} - GuildId: {et.GuildId} - UserId: {et.UserId} - Starts: {et.StartsAt} - Ends: {et.EndsAt} - IsConsumed: {et.IsConsumed} - SKU: {et.SkuId}\n");```
you could do something like this to get better info from it
what doies this mean
It just displays all of the info
Not just repeating the skuid
I thought it would only return:
1282452500913328180
1169107771673812992
It's getting all of the entitlements that users have on the bot
Not the individual sku info
oh so it means exactly how many users have them?
or well for each user with them it lists it?
listing your skus like this would be:
var data = await discord.Rest.GetSKUsAsync();
int count = 0;
var results = data.Aggregate("", (current, sku) => current + $"[{count++}] ID: {sku.Id} - Type: {sku.Type} - Name: {sku.Name} - Slug: {sku.Slug} - Created: {sku.CreatedAt}\n");
await ReplyAsync("Results: " + data.Count() + "\n" +
"\`\`\`\n" +
results +
"\n\`\`\`");
GetSKUsAsync:
Get each premium offering/sku/package that is configured on your bot
GetEntitlementsAsync:
Gets each user who has purchased a sku, and lists all of the skus/entitlements they have
basically
but yeah those two chunks of code should give you fairly detailed info about your SKUs and those who have purchased them
yeah I have determined there actually two users who purchased lifetime, but this is the first time an issue with it has ever been brought up.....
I wish discord dev portal had better support of stats for durables
ye
but, the user who you were having issues with initially was listed when you called the GetEntitlementsAsync method manually?
yes
hm weird
Misha is doing some debug testing, but running into alot of uh... "discord moments" with the system lol
so true
tbh I never even tested my system with lifetime premium
bc setting a test up was so hard
no u
hey buttface remind me to dip into this shit in 20 hours
... (#6491584) (20h | <t:1737746724>)
so for now I should just implement the work around
if you need it urgently, probably yeah
out ofcuriosity, does the ispremium check work correctly for the other lifetime user?
well uh
that is why I was so shocked
they have never brought anything up
and I have no clue who they are
🙂
lmao
could try to buy it yourself and see if you run into the same issue i guess
lol
I am trying my best to avoid that bc moneys
conflicted though, tbh I never thought I would get premium users
so it made more sense to just trust my coding abilities than pay money to test
you can do CreateTestEntitlementAsync
actually i dont think those work for durables
hold on
Using Live Entitlements
If you'd like to test the full payment flow for your app, you can do so by interacting with your Store page or a premium styled button. Any team members associated with your app will automatically see a 100% discount on the price of the subscription, allowing you to purchase without the use of live payment method.
Yeah thought so, if you purchase its free for you
Whether you're having issues with Bob, wanting to suggest a new idea, or maybe just wanna hang...
You can get one-time purchaseables for free in app testin mode
settings => advanced => app testing mode => paste your bot's id
then you won't get to the checkout, it will just grant you with whatever you "purchase"
if only it fucking showed up in the first place
oh yeah, that seems to work too
do I need to locally host it for this to work?
nah
ok
yeah I verified the entitlement existed
it was not present in the logging from IsPremium
@sage kraken: dip into this shit (20h ago)
well the good news is that I have filed one bug report for one-time purchase SKUs not showing up at all in the store
the bad is that I could not reproduce the issue
Or....
I think I managed to reproduce it
odd
I at the very least have a temporary work around out now which has provably worked so it is less pressing
honestly i thought they would care about this one
cuz like
its money
but oh well
well lets hope someone actually gets ashamed lel
