From ba729daf54511039bb4bc667121a6d0b8a869530 Mon Sep 17 00:00:00 2001 From: flifloo Date: Wed, 8 Apr 2020 18:32:56 +0200 Subject: [PATCH] Avoid some multi error handling --- extensions/extension.py | 15 ++++++++------- extensions/purge.py | 11 ++++++----- extensions/speak.py | 11 ++++++----- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/extensions/extension.py b/extensions/extension.py index 26db6b0..be97d44 100644 --- a/extensions/extension.py +++ b/extensions/extension.py @@ -55,13 +55,14 @@ class Extension(commands.Cog): @commands.Cog.listener() async def on_command_error(self, ctx: commands.Context, error): - if isinstance(error, NotOwner): - await ctx.message.add_reaction("\u274C") - elif isinstance(error, CommandNotFound): - await ctx.message.add_reaction("\u2753") - else: - await ctx.send("An error occurred !") - raise error + if ctx.invoked_with == extension_name: + if isinstance(error, NotOwner): + await ctx.message.add_reaction("\u274C") + elif isinstance(error, CommandNotFound): + await ctx.message.add_reaction("\u2753") + else: + await ctx.send("An error occurred !") + raise error def setup(bot): diff --git a/extensions/purge.py b/extensions/purge.py index 5ce6e40..5f1622f 100644 --- a/extensions/purge.py +++ b/extensions/purge.py @@ -71,11 +71,12 @@ class Purge(commands.Cog): @commands.Cog.listener() async def on_command_error(self, ctx: commands.Context, error): - if isinstance(error, CommandNotFound): - await ctx.message.add_reaction("\u2753") - else: - await ctx.send("An error occurred !") - raise error + if ctx.invoked_with == extension_name: + if isinstance(error, CommandNotFound): + await ctx.message.add_reaction("\u2753") + else: + await ctx.send("An error occurred !") + raise error def setup(bot): diff --git a/extensions/speak.py b/extensions/speak.py index af0738b..ff41f6d 100644 --- a/extensions/speak.py +++ b/extensions/speak.py @@ -165,11 +165,12 @@ class Speak(commands.Cog): @commands.Cog.listener() async def on_command_error(self, ctx: commands.Context, error): - if isinstance(error, CommandNotFound): - await ctx.message.add_reaction("\u2753") - else: - await ctx.send("An error occurred !") - raise error + if ctx.invoked_with == extension_name: + if isinstance(error, CommandNotFound): + await ctx.message.add_reaction("\u2753") + else: + await ctx.send("An error occurred !") + raise error def setup(bot):