mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-25 18:43:00 +00:00 
			
		
		
		
	[commands] Guarantee that local error handler is called before generic.
This commit is contained in:
		| @@ -632,7 +632,7 @@ class BotBase(GroupMixin): | |||||||
|             try: |             try: | ||||||
|                 yield from ctx.command.invoke(ctx) |                 yield from ctx.command.invoke(ctx) | ||||||
|             except CommandError as e: |             except CommandError as e: | ||||||
|                 ctx.command.dispatch_error(e, ctx) |                 yield from ctx.command.dispatch_error(e, ctx) | ||||||
|             else: |             else: | ||||||
|                 self.dispatch('command_completion', ctx) |                 self.dispatch('command_completion', ctx) | ||||||
|         elif ctx.invoked_with: |         elif ctx.invoked_with: | ||||||
|   | |||||||
| @@ -145,18 +145,18 @@ class Command: | |||||||
|         self.parent = None |         self.parent = None | ||||||
|         self._buckets = CooldownMapping(kwargs.get('cooldown')) |         self._buckets = CooldownMapping(kwargs.get('cooldown')) | ||||||
|  |  | ||||||
|  |     @asyncio.coroutine | ||||||
|     def dispatch_error(self, error, ctx): |     def dispatch_error(self, error, ctx): | ||||||
|         try: |         try: | ||||||
|             coro = self.on_error |             coro = self.on_error | ||||||
|         except AttributeError: |         except AttributeError: | ||||||
|             pass |             pass | ||||||
|         else: |         else: | ||||||
|             loop = ctx.bot.loop |  | ||||||
|             injected = wrap_callback(coro) |             injected = wrap_callback(coro) | ||||||
|             if self.instance is not None: |             if self.instance is not None: | ||||||
|                 discord.compat.create_task(injected(self.instance, error, ctx), loop=loop) |                 yield from injected(self.instance, error, ctx) | ||||||
|             else: |             else: | ||||||
|                 discord.compat.create_task(injected(error, ctx), loop=loop) |                 yield from injected(error, ctx) | ||||||
|         finally: |         finally: | ||||||
|             ctx.bot.dispatch('command_error', error, ctx) |             ctx.bot.dispatch('command_error', error, ctx) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user