aboutsummaryrefslogtreecommitdiff
path: root/cogs/errorhandler.py
diff options
context:
space:
mode:
authorLuca Matei Pintilie <lucafulger@gmail.com>2020-09-27 10:40:27 +0000
committerGitHub <noreply@github.com>2020-09-27 10:40:27 +0000
commit74cc1bcbab8bf54d4d6be420c87a82e06a707b3a (patch)
tree0ffef5d0b0af4d8fa75cdcb85b3953612f90b3a5 /cogs/errorhandler.py
parent4cbf4910ed2cea0c15497c8f911af2ba7e3b89d0 (diff)
parent6666649bcb48f8251456064b4b28d34e57e2f43e (diff)
downloadsteve-bot-74cc1bcbab8bf54d4d6be420c87a82e06a707b3a.tar
steve-bot-74cc1bcbab8bf54d4d6be420c87a82e06a707b3a.tar.gz
steve-bot-74cc1bcbab8bf54d4d6be420c87a82e06a707b3a.tar.bz2
steve-bot-74cc1bcbab8bf54d4d6be420c87a82e06a707b3a.tar.lz
steve-bot-74cc1bcbab8bf54d4d6be420c87a82e06a707b3a.tar.xz
steve-bot-74cc1bcbab8bf54d4d6be420c87a82e06a707b3a.tar.zst
steve-bot-74cc1bcbab8bf54d4d6be420c87a82e06a707b3a.zip
Merge pull request #31 from Skycloudd/master
Add global error handler + pending cooldown
Diffstat (limited to '')
-rw-r--r--cogs/errorhandler.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/cogs/errorhandler.py b/cogs/errorhandler.py
new file mode 100644
index 0000000..8533a61
--- /dev/null
+++ b/cogs/errorhandler.py
@@ -0,0 +1,20 @@
+from discord.ext import commands
+
+
+class Errorhandler(commands.Cog):
+ def __init__(self, bot):
+ self.bot = bot
+
+ @commands.Cog.listener()
+ async def on_command_error(self, ctx, error):
+ if isinstance(error, commands.CommandNotFound):
+ return
+
+ if isinstance(error, commands.CommandOnCooldown):
+ return await ctx.send(f'{ctx.author.mention}, you have to wait {round(error.retry_after, 2)} seconds before using this again')
+
+ raise error
+
+
+def setup(bot):
+ bot.add_cog(Errorhandler(bot))