diff options
| author | 2019-04-05 21:57:01 +0530 | |
|---|---|---|
| committer | 2019-04-05 21:57:01 +0530 | |
| commit | e590dcd137a9c86b3b7b6d48b5d72d0fc395a768 (patch) | |
| tree | 69a8111e913687e278803e336bf316cc1d7d562b /bot/decorators.py | |
| parent | Merge pull request #1 from python-discord/master (diff) | |
| parent | Merge pull request #184 from RohanRadia/master (diff) | |
Merge branch 'master' of https://github.com/python-discord/seasonalbot
Diffstat (limited to '')
| -rw-r--r-- | bot/decorators.py | 10 | 
1 files changed, 8 insertions, 2 deletions
| diff --git a/bot/decorators.py b/bot/decorators.py index f5ffadf4..15f7fed2 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -14,6 +14,8 @@ log = logging.getLogger(__name__)  def with_role(*role_ids: int): +    """Check to see whether the invoking user has any of the roles specified in role_ids.""" +      async def predicate(ctx: Context):          if not ctx.guild:  # Return False in a DM              log.debug(f"{ctx.author} tried to use the '{ctx.command.name}'command from a DM. " @@ -32,6 +34,8 @@ def with_role(*role_ids: int):  def without_role(*role_ids: int): +    """Check whether the invoking user does not have all of the roles specified in role_ids.""" +      async def predicate(ctx: Context):          if not ctx.guild:  # Return False in a DM              log.debug(f"{ctx.author} tried to use the '{ctx.command.name}' command from a DM. " @@ -47,6 +51,8 @@ def without_role(*role_ids: int):  def in_channel(channel_id): +    """Check that the command invocation is in the channel specified by channel_id.""" +      async def predicate(ctx: Context):          check = ctx.channel.id == channel_id          log.debug(f"{ctx.author} tried to call the '{ctx.command.name}' command. " @@ -58,8 +64,8 @@ def in_channel(channel_id):  def locked():      """      Allows the user to only run one instance of the decorated command at a time. -    Subsequent calls to the command from the same author are -    ignored until the command has completed invocation. + +    Subsequent calls to the command from the same author are ignored until the command has completed invocation.      This decorator has to go before (below) the `command` decorator.      """ | 
