diff options
author | Skycloudd <51929172+Skycloudd@users.noreply.github.com> | 2020-09-27 10:06:57 +0000 |
---|---|---|
committer | Skycloudd <51929172+Skycloudd@users.noreply.github.com> | 2020-09-27 10:06:57 +0000 |
commit | b9ac88864c832e0283c4fdcb9041900533f8807b (patch) | |
tree | 7f8bfbf0e09305d45806d8ddef744dccbe9a802a | |
parent | 4cbf4910ed2cea0c15497c8f911af2ba7e3b89d0 (diff) | |
download | steve-bot-b9ac88864c832e0283c4fdcb9041900533f8807b.tar steve-bot-b9ac88864c832e0283c4fdcb9041900533f8807b.tar.gz steve-bot-b9ac88864c832e0283c4fdcb9041900533f8807b.tar.bz2 steve-bot-b9ac88864c832e0283c4fdcb9041900533f8807b.tar.lz steve-bot-b9ac88864c832e0283c4fdcb9041900533f8807b.tar.xz steve-bot-b9ac88864c832e0283c4fdcb9041900533f8807b.tar.zst steve-bot-b9ac88864c832e0283c4fdcb9041900533f8807b.zip |
add global error handler
handles these errors:
- CommandNotFound (does nothing)
- CommandOnCooldown (does nothing)
-rwxr-xr-x | bot.py | 1 | ||||
-rw-r--r-- | cogs/errorhandler.py | 20 |
2 files changed, 21 insertions, 0 deletions
@@ -16,6 +16,7 @@ extensions = [ # "cogs.webserver", # "cogs.twitter", "cogs.logs", + "cogs.errorhandler" ] diff --git a/cogs/errorhandler.py b/cogs/errorhandler.py new file mode 100644 index 0000000..e3483c8 --- /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 + + raise error + + +def setup(bot): + bot.add_cog(Errorhandler(bot)) |