'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)
Solution 1:[1]
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)
Solution 2:[2]
try
await ctx.guild.create_text_channel('?~ " + user.name +" ~?', category=category, overwrites = perms)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Noriz |
