aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-05-10 17:49:42 -0400
committerRapptz <[email protected]>2017-05-10 17:49:42 -0400
commita2c9cefac9a44bd794b5bf2c4c9946e5ccd82f3c (patch)
treec62966afbeeab232dd8c216bbde51ea5b7bf2e66
parentOnly set the attribute if it isn't None. (diff)
downloaddiscord.py-a2c9cefac9a44bd794b5bf2c4c9946e5ccd82f3c.tar.xz
discord.py-a2c9cefac9a44bd794b5bf2c4c9946e5ccd82f3c.zip
[commands] Re-order error handler arguments.
They now have Context as the first argument to be consistent with other context-passing functions.
-rw-r--r--discord/ext/commands/bot.py4
-rw-r--r--discord/ext/commands/core.py10
2 files changed, 7 insertions, 7 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index 33796f98..6d45f275 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -740,13 +740,13 @@ class BotBase(GroupMixin):
try:
yield from ctx.command.invoke(ctx)
except CommandError as e:
- yield from ctx.command.dispatch_error(e, ctx)
+ 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))
- self.dispatch('command_error', exc, ctx)
+ self.dispatch('command_error', ctx, exc)
@asyncio.coroutine
def process_commands(self, message):
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 2f6eda14..48223895 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -164,7 +164,7 @@ class Command:
self._after_invoke = None
@asyncio.coroutine
- def dispatch_error(self, error, ctx):
+ def dispatch_error(self, ctx, error):
cog = self.instance
try:
coro = self.on_error
@@ -173,9 +173,9 @@ class Command:
else:
injected = wrap_callback(coro)
if cog is not None:
- yield from injected(cog, error, ctx)
+ yield from injected(cog, ctx, error)
else:
- yield from injected(error, ctx)
+ yield from injected(ctx, error)
try:
local = getattr(cog, '_{0.__class__.__name__}__error'.format(cog))
@@ -183,9 +183,9 @@ class Command:
pass
else:
wrapped = wrap_callback(local)
- yield from wrapped(error, ctx)
+ yield from wrapped(ctx, error)
finally:
- ctx.bot.dispatch('command_error', error, ctx)
+ ctx.bot.dispatch('command_error', ctx, error)
def __get__(self, instance, owner):
if instance is not None: