Answer the question
In order to leave comments, you need to log in
How to make use of command by role?
If you know how to make bots in the discord, then you know the command
. She makes the command so that only the admin can execute the command, but how can you make another role, for example, a moderator, be able to use it too?
Answer the question
In order to leave comments, you need to log in
discord.ext.commands.has_any_role(*items)
A check() that is added that checks if the member invoking the command has any of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.
Similar to has_role(), the names or IDs passed in must be exact.
This check raises one of two special exceptions, MissingAnyRole if the user is missing all roles, or NoPrivateMessage if it is used in a private message. Both inherit from CheckFailure.
Changed in version 1.1: Raise MissingAnyRole or NoPrivateMessage instead of generic CheckFailure
Parameters
items (List[Union[str, int]]) – An argument list of names or IDs to check that the member has roles wise.
Example
content_copy
@bot.command()
@commands.has_any_role('Library Devs', 'Moderators', 492212595072434186)
async def cool(ctx):
await ctx.send('You are cool indeed')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question