From 155ca221fad90e15ddbd26b5ea8b7852c87f6bb6 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Tue, 3 Aug 2021 18:30:26 -0600 Subject: [PATCH] Reset cooldown on unintended error --- jarvis/cogs/error.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jarvis/cogs/error.py b/jarvis/cogs/error.py index 6009ce8..b8284b1 100644 --- a/jarvis/cogs/error.py +++ b/jarvis/cogs/error.py @@ -1,4 +1,5 @@ from discord.ext import commands +from discord_slash import SlashContext class ErrorHandlerCog(commands.Cog): @@ -6,20 +7,22 @@ class ErrorHandlerCog(commands.Cog): self.bot = bot @commands.Cog.listener() - async def on_command_error(self, ctx, error): + async def on_command_error(self, ctx: commands.Context, error): if isinstance(error, commands.errors.MissingPermissions): await ctx.send("I'm afraid I can't let you do that.") elif isinstance(error, commands.errors.CommandNotFound): return elif isinstance(error, commands.errors.CommandOnCooldown): await ctx.send( - "Command on cooldown. Please wait before trying again", + "Command on cooldown. " + + f"Please wait {error.retry_after:0.2f}s before trying again", ) else: await ctx.send(f"Error processing command:\n```{error}```") + ctx.command.reset_cooldown(ctx) @commands.Cog.listener() - async def on_slash_command_error(self, ctx, error): + async def on_slash_command_error(self, ctx: SlashContext, error): if isinstance(error, commands.errors.MissingPermissions) or isinstance( error, commands.errors.CheckFailure ): @@ -37,6 +40,7 @@ class ErrorHandlerCog(commands.Cog): f"Error processing command:\n```{error}```", hidden=True, ) + ctx.command.reset_cooldown(ctx) def setup(bot):