role specific command

2019-03-02 02:32发布

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

1条回答
男人必须洒脱
2楼-- · 2019-03-02 02:50

You can use the discord.ext.commands extension, which offers a has_any_role decorator.

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))
查看更多
登录 后发表回答