[commands] Add Context.command_failed attribute.

This commit is contained in:
Rapptz 2017-01-27 17:14:22 -05:00
parent 1cf7b0e2c8
commit 8fa50a8f3e
2 changed files with 12 additions and 7 deletions

View File

@ -627,6 +627,7 @@ class BotBase(GroupMixin):
except CommandError as e:
yield from ctx.command.dispatch_error(e, ctx)
else:
ctx.command_failed = False
self.dispatch('command_completion', ctx)
elif ctx.invoked_with:
exc = CommandNotFound('Command "{}" is not found'.format(ctx.invoked_with))

View File

@ -67,6 +67,9 @@ class Context(discord.abc.Messageable):
to point to a valid registered subcommand and could just point to a
nonsense string. If nothing was passed to attempt a call to a
subcommand then this is set to `None`.
command_failed: bool
A boolean that indicates if the command failed to be parsed, checked,
or invoked.
"""
def __init__(self, **attrs):
@ -80,6 +83,7 @@ class Context(discord.abc.Messageable):
self.invoked_with = attrs.pop('invoked_with', None)
self.invoked_subcommand = attrs.pop('invoked_subcommand', None)
self.subcommand_passed = attrs.pop('subcommand_passed', None)
self.command_failed = attrs.pop('command_failed', True)
self._state = self.message._state
@asyncio.coroutine