diff options
| -rw-r--r-- | bot/cogs/free.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/bot/cogs/free.py b/bot/cogs/free.py index 7447fd941..6b06eaa4c 100644 --- a/bot/cogs/free.py +++ b/bot/cogs/free.py @@ -2,9 +2,10 @@ import logging from datetime import datetime from discord import Colour, Embed, Member, utils +from discord.ext import commands from discord.ext.commands import BucketType, Context, command, cooldown -from bot.constants import Categories, Free +from bot.constants import Categories, Free, Roles log = logging.getLogger(__name__) @@ -83,6 +84,26 @@ class Free: await ctx.send(embed=embed) + @free.error + async def free_error(self, ctx: Context, error): + """ + Runs if any error is raised during invocation + of !free command. Any error aside from + CommandOnCooldown is ignored. + + If error raised is CommandOnCooldown, and the + user who invoked has the helper role, reset + the cooldown and reinvoke the command. + """ + helpers = ctx.guild.get_role(Roles.helpers) + + if isinstance(error, commands.CommandOnCooldown): + if helpers in ctx.author.roles: + # reset cooldown so second invocation + # doesn't bring us back here. + ctx.command.reset_cooldown(ctx) + await ctx.invoke(ctx.command) + def setup(bot): bot.add_cog(Free()) |