[commands] Add the concept of global checks.
Global checks are checks that are executed before regular per-command checks except done to every command that the bot has registered. This allows you to have checks that apply to every command without having to override `on_message` or appending the check to every single command.
This commit is contained in:
@@ -395,8 +395,11 @@ class Command:
|
||||
if self.no_pm and ctx.message.channel.is_private:
|
||||
raise NoPrivateMessage('This command cannot be used in private messages.')
|
||||
|
||||
if not ctx.bot.can_run(ctx):
|
||||
raise CheckFailure('The global check functions for command {0.qualified_name} failed.'.format(self))
|
||||
|
||||
if not self.can_run(ctx):
|
||||
raise CheckFailure('The check functions for command {0.name} failed.'.format(self))
|
||||
raise CheckFailure('The check functions for command {0.qualified_name} failed.'.format(self))
|
||||
|
||||
@asyncio.coroutine
|
||||
def invoke(self, ctx):
|
||||
|
||||
Reference in New Issue
Block a user