Discord.py 当bot尝试删除角色冲突时出错

Discord.py 当bot尝试删除角色冲突时出错,discord.py,Discord.py,我正在尝试让机器人选择一个数字,然后删除您的角色或执行其他操作,但出现错误“discord.member没有属性remove_roles” 这是我的缩写代码: n = random.randint(0,2) if n==2: embed=discord.Embed(title='Nuke',description='Since I am very smart I nuked your role, so you are ded there goes your role =)'

我正在尝试让机器人选择一个数字,然后删除您的角色或执行其他操作,但出现错误“discord.member没有属性remove_roles” 这是我的缩写代码:

n = random.randint(0,2)

  if n==2:
        embed=discord.Embed(title='Nuke',description='Since I am very smart I nuked your role, so you are ded there goes your role =)')
        await ctx.send(embed=embed)
        await member.remove_roles(849202150097944628,reason=None,atomic=True)
      else:
        embed=discord.Embed(title='Nuke',description='Lucky You! The nuke missed, it hit farms so your kinda not fine!')
        await ctx.send(embed=embed)

您的问题是您的呼叫使用了错误的参数。该函数接受一个discord.Role的列表,但您只给了它角色id(假设它是一个)

通过获取角色对象

role=ctx.guild.get_角色(849202150097944628)
把这个拿走

role=ctx.guild.get_角色(849202150097944628)
等待成员。删除_角色([role],reason=None,atomic=True)

您的错误与代码不符!你说错误是
discord.member没有属性remove_role
,这是真的,因为函数被调用(注意's'),但在你的代码中拼写正确?是的,抱歉remove_roles我的意思是如何获得公会中的所有角色?使用
ctx.guild.roles
定义,以便我可以打印(ctx.guild.roles)?技术上,对如果您只想打印姓名,可以使用类似于
print([role.name for role in ctx.guild.roles])