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()
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):

View file

@ -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):

View file

@ -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):