aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mathsman5133 <[email protected]>2019-10-13 17:03:06 +1100
committerGravatar mathsman5133 <[email protected]>2019-10-13 17:03:06 +1100
commit5ebb87d4dbdf2c4c415f4a37b01746909f2b67b9 (patch)
tree3e8e502645a318e58ab2695a2d8a721ef8409fa6
parentMinor formatting changes to align with current help. (diff)
Add a special case for when the help command invokes wolfram checks.
- Before, running `!help` would invoke the cooldown check, and increase the cooldown counter unnecessarily as no wolfram API calls were being made. - Once `!help` was called enough, the bot would send an error embed to let you know your wolfram cooldown has expired.
-rw-r--r--bot/cogs/wolfram.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/bot/cogs/wolfram.py b/bot/cogs/wolfram.py
index ab0ed2472..3da349bd1 100644
--- a/bot/cogs/wolfram.py
+++ b/bot/cogs/wolfram.py
@@ -59,6 +59,14 @@ def custom_cooldown(*ignore: List[int]) -> Callable:
A list of roles may be provided to ignore the per-user cooldown
"""
async def predicate(ctx: Context) -> bool:
+ if ctx.invoked_with == 'help':
+ # if the invoked command is help we don't want to increase the ratelimits since it's not actually
+ # invoking the command/making a request, so instead just check if the user/guild are on cooldown.
+ guild_cooldown = not guildcd.get_bucket(ctx.message).get_tokens() == 0 # if guild is on cooldown
+ if not any(r.id in ignore for r in ctx.author.roles): # check user bucket if user is not ignored
+ return guild_cooldown and not usercd.get_bucket(ctx.message).get_tokens() == 0
+ return guild_cooldown
+
user_bucket = usercd.get_bucket(ctx.message)
if all(role.id not in ignore for role in ctx.author.roles):