aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Derek <[email protected]>2019-01-09 17:55:40 -0500
committerGravatar Derek <[email protected]>2019-01-09 17:55:40 -0500
commit2340509a482d2ed3fce2e3ede456ac49b2a97c43 (patch)
treefedbae381ae8955c864f5c9fa3f41495e6cc88c4
parentAdd activity timeout constant (diff)
Add exemption from cooldown for helpers
-rw-r--r--bot/cogs/free.py23
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())