如何让某人需要角色才能使用命令?
How to make someone need a role to use a command?
我正在制作一个不和谐的机器人,我想知道如何让某人需要一个必需的角色才能使用命令。
@bot.command(pass_context = True)
@commands.cooldown(1, 30, commands.BucketType.user)
async def test(ctx):
if commands.has_role("| Premium |"):
msg = ["test", "test2"]
await bot.send_message(ctx.message.author,
random.choice(msg))
请告诉我正确的方法,因为如果 commands.has_role("| Premium |"): 是不正确的
要添加基于用户角色名称的检查,请使用 commands.has_role() or commands.has_any_role() 装饰器。
@bot.command()
@commands.has_any_role("Premium")
async def test():
pass
我正在制作一个不和谐的机器人,我想知道如何让某人需要一个必需的角色才能使用命令。
@bot.command(pass_context = True)
@commands.cooldown(1, 30, commands.BucketType.user)
async def test(ctx):
if commands.has_role("| Premium |"):
msg = ["test", "test2"]
await bot.send_message(ctx.message.author,
random.choice(msg))
请告诉我正确的方法,因为如果 commands.has_role("| Premium |"): 是不正确的
要添加基于用户角色名称的检查,请使用 commands.has_role() or commands.has_any_role() 装饰器。
@bot.command()
@commands.has_any_role("Premium")
async def test():
pass