From 1778f2def1f9a95da00b6fa35f10afec74c68782 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 8 Jun 2020 21:43:20 +0100 Subject: [PATCH] Moved error handling to the main program EnsoBot.py --- EnsoBot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/EnsoBot.py b/EnsoBot.py index b481c768..61bc1d3b 100644 --- a/EnsoBot.py +++ b/EnsoBot.py @@ -46,6 +46,17 @@ async def on_command_error(ctx, error): await message.delete() +@client.event +async def on_command_error(ctx, target: discord.member): + if isinstance(target, commands.MissingRequiredArgument): + message = await ctx.send("Uh oh! Couldn't find anyone to mention! Try again!") + + # Let the user read the message for 2.5 seconds + await asyncio.sleep(1.5) + # Delete the message + await message.delete() + + try: client.run(API_TOKEN) except discord.errors.LoginFailure as e: