lolita
lolita

Reputation: 43

AttributeError: 'int' object has no attribute 'id' discord.py

im trying to make a discord.py function that creates a 'secret' channel with the name of a user but whenever i run the function

i get this error

in _create_channel parent_id = category.id if category else None AttributeError: 'int' object has no attribute 'id'

idek why theres an int or id error since im not trying to use either object or attribute

heres the code:

@client.command()
async def channel(ctx, user : discord.User):
  perms = {
    ctx.guild.default_role: discord.PermissionOverwrite(read_messages=False),
    user: discord.PermissionOverwrite(read_messages=True)}
  await ctx.guild.create_text_channel("♥~ " + user.name +" ~♥", category=category, overwrites = perms)

Upvotes: 1

Views: 936

Answers (2)

3nws
3nws

Reputation: 1439

Assuming category is the category id. You need to get the CategoryChannel object from ctx.guild.categories and pass that as category in create_text_channel().

category_channel = discord.utils.get(ctx.guild.categories, id=category)
await ctx.guild.create_text_channel("♥~ " + user.name +" ~♥", category=category_channel, overwrites = perms)

Upvotes: 3

Noriz
Noriz

Reputation: 73

try

 await ctx.guild.create_text_channel('♥~ " + user.name +" ~♥', category=category, overwrites = perms)

Upvotes: 0

Related Questions