#TypeError: sequence item 0: expected str instance, int found

1 messages · Page 1 of 1 (latest)

prisma adder
#

Hello !

I tried since few days now to get the valid entitlements of a server without database, to check if the server subscribed to my bot SKU.

But I can't see it on a server I have bought from myself the entitlement for the server.

Here is the code I have used :

    async def has_premium(self, entitlements):
        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
        
        print([[entitlement.sku_id, entitlement.application_id] async for entitlement in entitlements])
        print(self.bot.premium_sku.id, self.bot.premium_sku.name)
        
        print(self.bot.premium_sku.id in [entitlement.sku_id async for entitlement in entitlements])
        return self.bot.premium_sku.id in [entitlement.sku_id async for entitlement in entitlements]

And here are the logs I have on the bot

#

Is there something wrong in my code or is the pycord source code not working as expected ?

prisma adder
#

TypeError: sequence item 0: expected str instance, int found

#

I have tried to edit my code and here is the error I have now :

    async def has_premium(self, guild):
        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
        
        print([[entitlement.sku_id, entitlement.application_id] async for entitlement in guild.entitlements(limit=None, exclude_ended=True, skus=[self.bot.premium_sku])])
        print(self.bot.premium_sku.id, self.bot.premium_sku.name)
        
        return self.bot.premium_sku.id in [entitlement.sku_id async for entitlement in guild.entitlements(limit=None, exclude_ended=True, skus=[self.bot.premium_sku])]

I have this error thrown :

Ignoring exception in command premium status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 138, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/commands/core.py", line 1078, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/app/cogs/premium/_config.py", line 52, in premium_status
    has_premium = await self.has_premium(ctx.guild)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/cogs/premium/_config.py", line 41, in has_premium
    print([entitlement async for entitlement in guild.entitlements(limit=None, skus=[self.bot.premium_sku])])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/iterators.py", line 126, in __anext__
    return await self.next()
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/iterators.py", line 1008, in next
    await self.fill_entitlements()
  File "/usr/local/lib/python3.12/site-packages/discord/iterators.py", line 1028, in fill_entitlements
    data = await self._retrieve_entitlements(self.retrieve)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/iterators.py", line 1048, in _retrieve_entitlements_before_strategy
    data = await self.get_entitlements(
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/discord/http.py", line 2936, in list_entitlements
    params["sku_ids"] = ",".join(sku_ids)
                        ^^^^^^^^^^^^^^^^^
TypeError: sequence item 0: expected str instance, int found

Does anyone know why I have this ?

prisma adder
#

if anyone can do a PR 🤷

prisma adder
#

btw, this error is only happening when we pass the args skus in the entitlements()

lyric narwhal
#

I dont have time rn, but posting an issue and tagging it with good first issue would be a good thing to do

prisma adder
#

okay I will do it, maybe posting the PR too if I have time, but I prefer to wait on one of my entitlements to be canceled to check if the "valid entitlements" is good too or if it needs more modifications before making the PR

prisma adder
#

it ends the 28 so I let this open until I have opened the PR / issue

lyric narwhal
#

Sounds good :)

prisma adder