aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-03-14 12:35:24 -0700
committerGravatar MarkKoz <[email protected]>2020-03-14 12:35:24 -0700
commit52ed9aa590a4c190f70778448ec926df4f2d0119 (patch)
tree5105667946db075598033deb4a6687350e1c63e0
parentRemove line that calls get_tags() method (diff)
Tags: use constant for command prefix in embed footer
* Add a constant for the footer text * Import constants module rather than its classes
-rw-r--r--bot/cogs/tags.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/bot/cogs/tags.py b/bot/cogs/tags.py
index fee24b2e7..09ce5a413 100644
--- a/bot/cogs/tags.py
+++ b/bot/cogs/tags.py
@@ -7,19 +7,20 @@ from typing import Callable, Dict, Iterable, List, Optional
from discord import Colour, Embed
from discord.ext.commands import Cog, Context, group
+from bot import constants
from bot.bot import Bot
-from bot.constants import Channels, Cooldowns
from bot.converters import TagNameConverter
from bot.pagination import LinePaginator
log = logging.getLogger(__name__)
TEST_CHANNELS = (
- Channels.bot_commands,
- Channels.helpers
+ constants.Channels.bot_commands,
+ constants.Channels.helpers
)
REGEX_NON_ALPHABET = re.compile(r"[^a-z]", re.MULTILINE & re.IGNORECASE)
+FOOTER_TEXT = f"To show a tag, type {constants.Bot.prefix}tags <tagname>."
class Tags(Cog):
@@ -133,7 +134,7 @@ class Tags(Cog):
sorted(f"**»** {tag['title']}" for tag in matching_tags),
ctx,
embed,
- footer_text="To show a tag, type !tags <tagname>.",
+ footer_text=FOOTER_TEXT,
empty=False,
max_lines=15
)
@@ -177,7 +178,7 @@ class Tags(Cog):
cooldown_conditions = (
tag_name
and tag_name in self.tag_cooldowns
- and (now - self.tag_cooldowns[tag_name]["time"]) < Cooldowns.tags
+ and (now - self.tag_cooldowns[tag_name]["time"]) < constants.Cooldowns.tags
and self.tag_cooldowns[tag_name]["channel"] == ctx.channel.id
)
@@ -186,7 +187,8 @@ class Tags(Cog):
return False
if _command_on_cooldown(tag_name):
- time_left = Cooldowns.tags - (time.time() - self.tag_cooldowns[tag_name]["time"])
+ time_elapsed = time.time() - self.tag_cooldowns[tag_name]["time"]
+ time_left = constants.Cooldowns.tags - time_elapsed
log.info(
f"{ctx.author} tried to get the '{tag_name}' tag, but the tag is on cooldown. "
f"Cooldown ends in {time_left:.1f} seconds."
@@ -223,7 +225,7 @@ class Tags(Cog):
sorted(f"**»** {tag['title']}" for tag in tags),
ctx,
embed,
- footer_text="To show a tag, type !tags <tagname>.",
+ footer_text=FOOTER_TEXT,
empty=False,
max_lines=15
)