title: How do you create a custom decorator for discord.py?
body: <p>I am working on a bot. For a certain cog, I wish to create a custom check decorator that checks to see if the person running the command has a certain role. The role is stored as a role class as an instance variable. When I tried running it, it doesn't work. How do you make the decorator?</p>
  
  <pre class="lang-py prettyprint-override"><code>class Moderation(commands.Cog):
      def __init__(self, bot: commands.Bot):
          self.bot = bot
          self.mod_role = None  # Assume there's already a role here
  
      class Decorator:
          @classmethod
          def requires_mod(cls, func):
              async def decorator(self, ctx: commands.Context, *args, **kwargs):
                  if self.mod_role not in ctx.author.roles:
                      await ctx.send("You do not have permission to use this command")
                  func(ctx, *args, **kwargs)
              return decorator
  
      @commands.command()
      @Decorator.requires_mod
      async def purge(self, ctx: commands.Context, amt: int):
          await ctx.channel.purge(limit=amt+1)
          await ctx.send(f":white_check_mark: | Deleted {amt} messages.")
  </code></pre>