我怎样才能做到只有具有特定角色的成员才能执行命令?

How can I make it so only members with a specific role can execute a command?

我的问题可能看起来很常见,但这次有一个转折点。我需要它来要求角色和特定角色之一,而不仅仅是少数角色之一。这是我试过但不起作用的代码

@bot.command()
@commands.has_any_role("Buffalo Bills")
@commands.has_any_role("Franchise Owner", "General Manager", "Head Coach", "Assistant Coach")

然后是我剩下的命令。

这是您可以做到的一种方法。使用 @commands.has_role() and @commands.has_any_role,您可以确保用户具有一个特定角色以及给定的角色之一。

@client.command()
@commands.has_role('Must Have Role')
@commands.has_any_role('Role One', 'Role Two')
async def role_test(ctx):
    await ctx.send("Hey this worked") 
# This would only send if the user has 'Must Have Role' and either 'Role One' or 'Role Two'