aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-06-27 16:16:25 -0700
committerGravatar MarkKoz <[email protected]>2020-06-27 16:16:25 -0700
commitb209997a294c8dd07f08e9f2e3ffdb5afc265285 (patch)
tree36ccf734b508a6f11b3be3e8a76914e413046e3b
parentCode block: make PY_LANG_CODES more visible (diff)
Code block: use config constant for cooldown
-rw-r--r--bot/cogs/codeblock/cog.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/bot/cogs/codeblock/cog.py b/bot/cogs/codeblock/cog.py
index 6032e911c..2576be966 100644
--- a/bot/cogs/codeblock/cog.py
+++ b/bot/cogs/codeblock/cog.py
@@ -83,12 +83,14 @@ class CodeBlockCog(Cog, name="Code Block"):
def is_on_cooldown(self, channel: discord.TextChannel) -> bool:
"""
- Return True if an embed was sent for `channel` in the last 300 seconds.
+ Return True if an embed was sent too recently for `channel`.
+ The cooldown is configured by `constants.CodeBlock.cooldown_seconds`.
Note: only channels in the `channel_cooldowns` have cooldowns enabled.
"""
log.trace(f"Checking if #{channel} is on cooldown.")
- return (time.time() - self.channel_cooldowns.get(channel.id, 0)) < 300
+ cooldown = constants.CodeBlock.cooldown_seconds
+ return (time.time() - self.channel_cooldowns.get(channel.id, 0)) < cooldown
def is_valid_channel(self, channel: discord.TextChannel) -> bool:
"""Return True if `channel` is a help channel, may be on a cooldown, or is whitelisted."""