1
0
Fork 0

Avoid some multi error handling

This commit is contained in:
Ethanell 2020-04-08 18:32:56 +02:00
parent c7a42e4497
commit ba729daf54
3 changed files with 20 additions and 17 deletions

View file

@ -55,13 +55,14 @@ class Extension(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error): async def on_command_error(self, ctx: commands.Context, error):
if isinstance(error, NotOwner): if ctx.invoked_with == extension_name:
await ctx.message.add_reaction("\u274C") if isinstance(error, NotOwner):
elif isinstance(error, CommandNotFound): await ctx.message.add_reaction("\u274C")
await ctx.message.add_reaction("\u2753") elif isinstance(error, CommandNotFound):
else: await ctx.message.add_reaction("\u2753")
await ctx.send("An error occurred !") else:
raise error await ctx.send("An error occurred !")
raise error
def setup(bot): def setup(bot):

View file

@ -71,11 +71,12 @@ class Purge(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error): async def on_command_error(self, ctx: commands.Context, error):
if isinstance(error, CommandNotFound): if ctx.invoked_with == extension_name:
await ctx.message.add_reaction("\u2753") if isinstance(error, CommandNotFound):
else: await ctx.message.add_reaction("\u2753")
await ctx.send("An error occurred !") else:
raise error await ctx.send("An error occurred !")
raise error
def setup(bot): def setup(bot):

View file

@ -165,11 +165,12 @@ class Speak(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error): async def on_command_error(self, ctx: commands.Context, error):
if isinstance(error, CommandNotFound): if ctx.invoked_with == extension_name:
await ctx.message.add_reaction("\u2753") if isinstance(error, CommandNotFound):
else: await ctx.message.add_reaction("\u2753")
await ctx.send("An error occurred !") else:
raise error await ctx.send("An error occurred !")
raise error
def setup(bot): def setup(bot):