Python 检查用户是否具有角色
我正在检查用户是否具有特定角色。我知道@commands.has_role(),但这对我正在制作的内容不起作用。我有下面的示例代码,我不确定如何让它检查用户是否拥有该角色Python 检查用户是否具有角色,python,discord,discord.py,Python,Discord,Discord.py,我正在检查用户是否具有特定角色。我知道@commands.has_role(),但这对我正在制作的内容不起作用。我有下面的示例代码,我不确定如何让它检查用户是否拥有该角色 @commands.command() 异步def hasthisroletest(自身,ctx): 如果ctx.author.role.id==74683126883186268: 等待ctx.send(“你做到了!”) 其他: 等待ctx发送(“否:(”) 您可以检查想要的角色是否存在 用于获取角色本身 @commands
@commands.command()
异步def hasthisroletest(自身,ctx):
如果ctx.author.role.id==74683126883186268:
等待ctx.send(“你做到了!”)
其他:
等待ctx发送(“否:(”)
您可以检查想要的角色是否存在
用于获取角色本身
@commands.command()
异步def hasthisroletest(ctx):
#您还可以使用name='Test_role'
role=discord.utils.get(ctx.guild.roles,id=74683126883186268)
如果角色在ctx.author.roles中:
等待ctx.send(“你做到了!”)
其他:
等待ctx发送(“否:(”)
您制作的内容的背景是什么?