#Handling Durables

1 messages · Page 1 of 1 (latest)

lament bobcat
#

I am a little confused of how to properly handle durables. Is it sent in the entitlements they have it, or only once via EntitlementCreated event

sage kraken
#

ENTITLEMENT_CREATE <=> EntitlementCreated
LIST Entitlements <=> GetEntitlementsAsync
Interaction Payloads <=> IDiscordInteraction.Entitlements

lament bobcat
#

oh, so I should make sure to save durable

sage kraken
#

it depends™️

#

if you only gonna check for it on command uses - there's no real need, since we have IDiscordInteraction.Entitlements

lament bobcat
#

so like if I had a lifetime premium durable, it is still sent in the entitlements?

sage kraken
#

yah

#

basically you get all entitlements applicable to that interaction context (guild/user subsriptions, one time purchasables )

lament bobcat
#

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

sage kraken
#

uh
well
that's interesting.

#

That's the second case of this happening as i remember

lament bobcat
#

oh dear

sage kraken
#

so uh

#

do you wanna just slap a temp solution

#

or go into the debugging rabbit hole

lament bobcat
#

what is the temp solution?

sage kraken
#

rest calls

#

doing a GetwhateverAsync for that user

#

but yah
I can't confirm whether this is a bug or not

lament bobcat
#

should I be concerned about ratelimiting from that?

sage kraken
#

probably

#

idr if I have implemented cache

#

I probably did

lament bobcat
#

on cakey?

#

or in dnet?

sage kraken
#

if there's a non-async method on the socket client - then I did

lament bobcat
#

ah ok

sage kraken
#

not sure though

sage kraken
# sage kraken or go into the debugging rabbit hole

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

lament bobcat
#
  • 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 GetEntitlementsAsync wait what does this do?
sage kraken
#

GetEntitlementsAsync
literally just does a rest GET request

#

DiscordSocketClient.GetEntitlementsAsync(userId: 691337) would get entitlements for a given user

vast pivot
#

What code are you using to pass the entitlements to this method?

lament bobcat
#

within a slash command like this:
IsPremium(Context.Interaction.Entitlements)

vast pivot
#

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)

lament bobcat
#

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.

vast pivot
#

are you on the latest DNet version?

sage kraken
#

should not matter

lament bobcat
#

I am though

sage kraken
#

I haven't touched that code since the initial release/discord's breakings

vast pivot
#

but if hes on latest wouldnt matter anyways

sage kraken
#

why can I not grant myself an sku wtf lol

vast pivot
#

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

lament bobcat
#

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
vast pivot
#

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
lament bobcat
vast pivot
#

Not just repeating the skuid

lament bobcat
#

I thought it would only return:

1282452500913328180

1169107771673812992
vast pivot
#

Not the individual sku info

lament bobcat
#

oh so it means exactly how many users have them?

#

or well for each user with them it lists it?

vast pivot
#

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

lament bobcat
#

oh

#

ok

vast pivot
#

but yeah those two chunks of code should give you fairly detailed info about your SKUs and those who have purchased them

lament bobcat
#

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

vast pivot
#

ye

#

but, the user who you were having issues with initially was listed when you called the GetEntitlementsAsync method manually?

lament bobcat
#

yes

vast pivot
#

hm weird

#

Misha is doing some debug testing, but running into alot of uh... "discord moments" with the system lol

lament bobcat
#

so true

#

tbh I never even tested my system with lifetime premium

#

bc setting a test up was so hard

sage kraken
#

It's fucking cursed

#

Discord i mean

#

and monetization too

vast pivot
sage kraken
#

hey buttface remind me to dip into this shit in 20 hours

rancid yachtBOT
#

... (#6491584) (20h | <t:1737746724>)

sage kraken
#

so true

#

...

lament bobcat
#

so for now I should just implement the work around

vast pivot
#

out ofcuriosity, does the ispremium check work correctly for the other lifetime user?

lament bobcat
#

well uh

#

that is why I was so shocked

#

they have never brought anything up

#

and I have no clue who they are

#

🙂

vast pivot
#

lmao

#

could try to buy it yourself and see if you run into the same issue i guess

#

lol

lament bobcat
#

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

vast pivot
#

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

lament bobcat
#

really? bc it does not seem free

vast pivot
#

looks like it only works on subscriptions, not durables too

#

thanks discord

lament bobcat
#

😦

#

ok thanks for checking again

vast pivot
#

its only $5, i can buy it lol

#

invite me to your server?

weary fractalBOT
#

Whether you're having issues with Bob, wanting to suggest a new idea, or maybe just wanna hang...

sage kraken
#

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

vast pivot
#

oh yeah, that seems to work too

lament bobcat
#

do I need to locally host it for this to work?

sage kraken
#

nah

lament bobcat
#

ok

sage kraken
#

ignore the host/port thing

#

that's for activities

#

you only need the bot id

lament bobcat
#

yeah I verified the entitlement existed

#

it was not present in the logging from IsPremium

rancid yachtBOT
sage kraken
#

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

lament bobcat
#

odd

#

I at the very least have a temporary work around out now which has provably worked so it is less pressing

sage kraken
#

@lament bobcat lmao
this may get acknowledged at least

lament bobcat
#

FINALLY

#

ngl

#

you would think they would care more

sage kraken
#

honestly i thought they would care about this one

#

cuz like
its money

#

but oh well

#

well lets hope someone actually gets ashamed lel

sage kraken
#

@lament bobcat NO WAY

#

Did u get this with real ones too?

#

Could you add it to the issue

sage kraken
#

the guy actually fixed it it looks like

#

woah