AttributeError:’int’对象没有属性’id’ discord.py

扎眼的阳光 python 209

原文标题AttributeError: ‘int’ object has no attribute ‘id’ discord.py

我正在尝试创建一个 discord.py 函数,该函数使用用户名创建一个“秘密”频道,但每当我运行该函数时

我得到这个错误

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

想知道为什么存在 int 或 id 错误,因为我没有尝试使用对象或属性

继承人的代码:

@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)

原文链接:https://stackoverflow.com//questions/71909975/attributeerror-int-object-has-no-attribute-id-discord-py

回复

我来回复
  • Noriz的头像
    Noriz 评论

    尝试

     await ctx.guild.create_text_channel('♥~ " + user.name +" ~♥', category=category, overwrites = perms)
    
    2年前 0条评论