Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 6c4a706

Browse files
authored
Update bot.py
1 parent edcde62 commit 6c4a706

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

bot.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,5 +466,23 @@ async def on_message(message):
466466
await ctx.send(output[:2000])
467467
f.close()
468468

469+
@bot.event
470+
async def on_command_error(ctx, error):
471+
if hasattr(ctx.command, 'on_error'):
472+
return
473+
error = getattr(error, 'original', error)
474+
if isinstance(error, commands.NoPrivateMessage):
475+
await ctx.send("Sorry, you can't use this command in a private message!")
476+
return
477+
if isinstance(error, commands.CommandNotFound):
478+
return
479+
if isinstance(error, commands.CommandOnCooldown):
480+
await ctx.send(error,delete_after=5)
481+
return
482+
last_msg = str(list(await ctx.channel.history(limit=1).flatten())[0].content)
483+
error_msg = f'```{error}```'
484+
if error_msg != last_msg:
485+
# Don't send from all users.
486+
await ctx.send(error_msg)
469487

470488
bot.run(YOUR_SECRET_TOKEN)

0 commit comments

Comments
 (0)