- 
            
      
        
      
    Star
      
          
          (126)
      
  
You must be signed in to star a gist  - 
              
      
        
      
    Fork
      
          
          (9)
      
  
You must be signed in to fork a gist  
- 
      
 - 
        
Save Painezor/eb2519022cd2c907b56624105f94b190 to your computer and use it in GitHub Desktop.  
| @commands.guild_only() | |
| # Command cannot be used in private messages. | |
| @commands.dm_only() | |
| # Command can only be used in private messages. | |
| @commands.is_owner() | |
| # Command can only be used by the bot owner. | |
| @commands.is_nsfw() | |
| # Command can only be used in NSFW channels | |
| @commands.has_role("name") | |
| # Check if member has a role with the name "name" | |
| @commands.bot_has_role(11132312313213) | |
| # As above, but for the bot itself. (name can be replaced with id) | |
| @commands.has_any_role("role1","foo",11132312313213) | |
| # Check if user has any of the roles with the names "role1", "foo", or the role with id 11132312313213 | |
| @commands.bot_has_any_role(*roles) | |
| # As above, but for the bot itself | |
| @commands.has_permissions(ban_members=True, kick_members=True) | |
| # Check if user has all of the passed permissions | |
| # e.g. this command will require both kick and ban permissions | |
| @commands.bot_has_permissions(**perms) | |
| # As above, but for the bot itself. | |
| @commands.has_guild_permissions(**perms) | |
| @commands.bot_has_guild_permissions(**perms) | |
| # As for the two above, but for guild permissions rather than channel permissions. | |
| @commands.check(myfunction) | |
| # Check against your own function that returns those able to use your command | |
| @commands.check_any(*myfunctions) | |
| # Command will be ran if the conditions of any of your own check functions are met | |
| from discord.ext.commands.cooldowns import BucketType | |
| # BucketType can be BucketType.default, member, user, guild, role, or channel | |
| @commands.cooldown(rate,per,BucketType) | |
| # Limit how often a command can be used, (num per, seconds, BucketType) | |
| @commands.max_concurrency(number, per=BucketType.default, *, wait=False) | |
| # Limit how many instances of the command can be running at the same time. | |
| # Setting wait=True will queue up additional commands. False will raise MaxConcurrencyReached | |
| # Checks can be stacked, and will Raise a CheckFailure if any check fails. | 
i still looked at this, very useful gist
thank u so much <3
You could do it by putting a
*before the variable (list) containing the roles in the parameters:roles = ['role_a', 'role_b', 'role_c'] @commands.has_any_role(*roles) @commands.command async def my_command(ctx): ...
Not working @CapClumpsy
@parthshingari28 Could you show your code, or contact me on discord at CaptainClumsy#3018, since just saying "Not working" isn't very helpful and I can't really tell what's the problem.
Can You give a example how to do it for Cogs , that will be very helpful for me .
@Mr-ROI what is "it", are you talking about the checks, or something else?
If you're talking about the checks, simply put the check decorator before a method that is being used for a command.
Is there an example as to how I could use my own function? What should the function return? Should it be true/false or a list of ID's?
@jeanravenclaw true/false yea
@FireRedz thanks!
Ok nvm i made a mistake in the code. I was inputing a list in the has_any_role() method.