简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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