角色特定命令

时间:2018-05-24 09:14:47

标签: python python-3.x discord discord.py

角色特定命令是的,它的工作终于得到了它。

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))

1 个答案:

答案 0 :(得分:1)

您可以使用提供has_any_role装饰器的discord.ext.commands扩展程序。

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))
相关问题