Avoid some multi error handling
This commit is contained in:
parent
c7a42e4497
commit
ba729daf54
3 changed files with 20 additions and 17 deletions
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Reference in a new issue