#Premium guild subscription check
1 messages · Page 1 of 1 (latest)
You have to check Interaction.entitlements
Ok thansk
Its with discord.Interaction attribute ?
not with Guild ?
He has no attribute without async ?
Or how to get it without await or async for ?
Or just a guild.get_entitlement(ID) or something like that
this is not an await to get the entitlements, but I am not able to check if the server bought it or not. Did you find any solution ?
yes, use the module asyncio to async the func without await
did you manage to get a check if the server has a premium subscription ?
I am trying to fetch it
but it does not tell you if the server paid for it, I got the exactly same result for a server that pay, and for another that does not pay
have you use the Guild.entitlements ?
yes ```py
guild_entitlements = ctx.guild.entitlements(skus=[complete_sku], exclude_ended=True)
print(complete_sku.id in guild_entitlements.sku_ids)
my code is under development thanks for warning me 😅
mine too lol
xD
So currently I don't think there is any way to get the status of a server subscription on the bot except if we store it in a database
in the entitlements you have the buyer, the end of subscribe and the deleted= (bool), its probably with this ?
the EntitlementIterator object seems to just return the informations I gave
complete_sku is the SKU object of what I want to check the server has.
if I just leave the ctx.guild.entitlements clear, I have an object full of None but my server has the subscription.
It does not tell if the server have paid in the shop for it
@potent thicket you know how to check if a server is premium ?
guild.entitlements is a coroutine
seems not in the docs
Then I was wrong and don't mind me lol
it isn't, but it's an AsyncIterator which requires async/await logic
as per the examples (you can use guild instead of client/user)
thanks !!
The flatten() method did not work for me but the async for loop worked
No one know how to check if a server is premium ?
use the async for loop, it works great
Its doesnt work perfectly
you have got errors ? I never had
He just not say I don't have premium
did you try something like this ?
if self.bot.premium_sku is None:
SKUS = await self.bot.fetch_skus()
for SKU in SKUS:
if SKU.name == "Unlock Premium Features":
self.bot.premium_sku = SKU
break
if self.bot.premium_sku.id not in [entitlement.sku_id async for entitlement in ctx.guild.entitlements()]:
...
this code works for me
Why the self.bot.premium_sku.id != entitlement.sku_id ?
if PREMIUM_SKU is None:
SKUS = await bot_ins.fetch_skus()
for SKU in SKUS:
print(SKU)
print(SKU.id)
if "AwaBot Premium" in SKU.name:
PREMIUM_SKU = SKU
break
if PREMIUM_SKU is None:
return False
async for entitlement in entitlements:
print(entitlement.sku_id)
if PREMIUM_SKU.id not in [entitlement.sku_id async for entitlement in entitlements]:
return False
return True
print =>
Entitlement:
1286039387246694430
1286039387246694430
Premium_sku =>
AwaBot Premium
1285648183673880576
what is stored into entitlements ?
the async for's print ?
yes
1286039387246694430
1286039387246694430
how do you get it in your command / event ?
its a function
uh ? show me your function then
async def is_premium(bot_ins, guild):
global PREMIUM_SKU
if not guild:
return False
if isinstance(guild, discord.Guild):
entitlements = guild.entitlements()
else:
guild_ins = bot_ins.get_guild(guild)
if not guild_ins:
return False
entitlements = guild_ins.entitlements()
if PREMIUM_SKU is None:
SKUS = await bot_ins.fetch_skus()
for SKU in SKUS:
print(SKU)
print(SKU.id)
if "AwaBot Premium" in SKU.name:
PREMIUM_SKU = SKU
break
if PREMIUM_SKU is None:
return False
async for entitlement in entitlements:
print(entitlement.sku_id)
if PREMIUM_SKU.id not in [entitlement.sku_id async for entitlement in entitlements]:
return False
return True
can you show the name of the SKU please ?
AwaBot Premium
I mean... of the ones you said, the SKU with ID 1286039387246694430
ok but why this debug return 1285648183673880576
this one is the right one, I would like to know what is the other one that finish by 30
This debug
replace entitlement.sku_id by entitlement.name
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Entitlement' object has no attribute 'name'
just go to https://discord.com/developers/applications/<your bot id>/skus/1286039387246694430/information and just send the name of it
are you sure the sku id is the one that finishes by 30 like I have put in the link ?
do the same with the 1285648183673880576 now
weird
so this is the not good result.
Maybe edit some code to be sure the good SKU is selected
the sku_id change for different guild
not for me, that's weird