mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 07:54:36 +00:00
[commands] Fix Context.command_failed from being incorrect.
When used, it would be set to False after the invoke was done. Ideally it should report to False during invoke but True during any error case.
This commit is contained in:
parent
8526995004
commit
c3e39cd722
@ -742,7 +742,6 @@ class BotBase(GroupMixin):
|
||||
except CommandError as e:
|
||||
yield from ctx.command.dispatch_error(ctx, e)
|
||||
else:
|
||||
ctx.command_failed = False
|
||||
self.dispatch('command_completion', ctx)
|
||||
elif ctx.invoked_with:
|
||||
exc = CommandNotFound('Command "{}" is not found'.format(ctx.invoked_with))
|
||||
|
@ -83,7 +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.command_failed = attrs.pop('command_failed', False)
|
||||
self._state = self.message._state
|
||||
|
||||
@asyncio.coroutine
|
||||
|
@ -61,10 +61,13 @@ def hooked_wrapped_callback(command, ctx, coro):
|
||||
try:
|
||||
ret = yield from coro(*args, **kwargs)
|
||||
except CommandError:
|
||||
ctx.command_failed = True
|
||||
raise
|
||||
except asyncio.CancelledError:
|
||||
ctx.command_failed = True
|
||||
return
|
||||
except Exception as e:
|
||||
ctx.command_failed = True
|
||||
raise CommandInvokeError(e) from e
|
||||
finally:
|
||||
yield from command.call_after_hooks(ctx)
|
||||
@ -165,6 +168,7 @@ class Command:
|
||||
|
||||
@asyncio.coroutine
|
||||
def dispatch_error(self, ctx, error):
|
||||
ctx.command_failed = True
|
||||
cog = self.instance
|
||||
try:
|
||||
coro = self.on_error
|
||||
|
Loading…
x
Reference in New Issue
Block a user