【发布时间】:2021-02-07 14:36:50
【问题描述】:
我正在尝试为我的 discord 机器人添加一个验证系统,其中一个执行 c.verify 以获得 Verified 角色,但我在分配角色时遇到了问题,并且我发现的所有内容都不起作用。这就是我所拥有的:
@commands.command(pass_context=True)
async def verify(self, ctx):
role = get(ctx.author.roles, name="TOS Verified")
if ctx.channel.id == 769016529450303519:
await ctx.message.delete()
await ctx.send(f"{ctx.author.mention} has been verified.")
sleep(1)
await ctx.channel.purge(limit = 1)
await bot.add_roles(ctx.message.author, role)
else:
await ctx.message.delete()
await ctx.send("You can not verify here.")
我得到的错误是“机器人没有属性 add_roles”。一切正常,直到必须添加角色,但我不知道为什么我不能添加角色。
【问题讨论】:
标签: python discord discord.py