简体   繁体   English

角色特定命令

[英]role specific command

role specific command yes its working finally got it. 角色特定命令是的,它的工作终于得到了它。

from discord.ext import commands

bot = commands.Bot('?')

@bot.command(pass_context=True)
@commands.has_any_role("Admin", "Moderator")
async def hello(ctx):
    await bot.say("Hello {}".format(ctx.message.author.mention))

You can use the discord.ext.commands extension, which offers a has_any_role decorator. 您可以使用discord.ext.commands扩展,它提供了一个has_any_role装饰。

from discord.ext import commands

bot = commands.Bot('?')

@bot.command(pass_context=True)
@commands.has_any_role("Admin", "Moderator")
async def hello(ctx):
    await bot.say("Hello {}".format(ctx.message.author.mention))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM