From 5acabf19bdb02242035904797090575665cd50c4 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 15 Jun 2020 00:00:04 +0100 Subject: [PATCH] Added error handling for people trying to use commands they don't have permission for --- EnsoBot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/EnsoBot.py b/EnsoBot.py index 35c5a737..37155cc1 100644 --- a/EnsoBot.py +++ b/EnsoBot.py @@ -58,6 +58,17 @@ async def on_command_error(ctx, target: discord.member): await message.delete() +@client.event +async def on_command_error(ctx, error): + if isinstance(error, commands.CheckFailure): + message = await ctx.send("Uh oh! You don't have permission to use this command!") + + # 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: