How to check whether a user has a role for the discord bot?

How can I check if a discord user has a role? I want to make a special role so that the bot executes commands only for those users who have this role, for example, "Admin". And if there is no role, he wrote that they need such and such a role. I don't know much about Python, library

Author: Levius, 2020-07-26

2 answers

There is such a thing: @commands.has_any_role() inside the parentheses of the role id separated by commas , or if you need a check inside the function, it is written like this: if role in member.roles: role - the role itself

 1
Author: Snowdy, 2020-08-10 09:59:35

There is an option

@commands.has_permissions(administrator = True)

The function will perform if the person has the administrator role

enter a description of the image here

 1
Author: Scyker, 2020-09-15 09:16:24