角色特定命令是的,它的工作终于得到了。
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))
最佳答案
您可以使用 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))
关于python - 角色特定命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50505434/