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 | |
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
-rwxr-xr-x | bot.py | 1 | ||||
-rw-r--r-- | cogs/errorhandler.py | 20 | ||||
-rwxr-xr-x | cogs/src.py | 1 | ||||
-rwxr-xr-x | cogs/utils.py | 8 |
4 files changed, 22 insertions, 8 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..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)) diff --git a/cogs/src.py b/cogs/src.py index 81285a1..d2da654 100755 --- a/cogs/src.py +++ b/cogs/src.py @@ -332,6 +332,7 @@ class Src(commands.Cog): async def is_mod(ctx): return ctx.author.guild_permissions.manage_channels + @commands.cooldown(300, 1, commands.BucketType.guild) @commands.command(description="Posts all pending runs to #pending-runs") @commands.guild_only() async def pending(self, ctx): diff --git a/cogs/utils.py b/cogs/utils.py index 3caca9e..1d3f3a8 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -366,14 +366,6 @@ class Utils(commands.Cog): "https://aninternettroll.github.io/mcbeVerifierLeaderboard/" ) - @leaderboard.error - async def leaderboard_handler(self, ctx, error): - if isinstance(error, commands.CommandOnCooldown): - # return - await ctx.send( - f"{discord.utils.escape_mentions(ctx.message.author.display_name)}, you have to wait {round(error.retry_after, 2)} seconds before using this again." - ) - @commands.cooldown(1, 60, commands.BucketType.guild) @commands.command() async def someone(self, ctx): |