Demotry
Demotry

Reputation: 909

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

Upvotes: 1

Views: 492

Answers (1)

Patrick Haugh
Patrick Haugh

Reputation: 60984

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

Upvotes: 3

Related Questions