diff options
author | Luca Matei Pintilie <lucafulger@gmail.com> | 2020-09-27 10:40:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-27 10:40:27 +0000 |
commit | 74cc1bcbab8bf54d4d6be420c87a82e06a707b3a (patch) | |
tree | 0ffef5d0b0af4d8fa75cdcb85b3953612f90b3a5 /cogs/errorhandler.py | |
parent | 4cbf4910ed2cea0c15497c8f911af2ba7e3b89d0 (diff) | |
parent | 6666649bcb48f8251456064b4b28d34e57e2f43e (diff) | |
download | steve-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.py | 20 |
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)) |