aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/pride
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/pride')
-rw-r--r--bot/exts/pride/drag_queen_name.py12
-rw-r--r--bot/exts/pride/pride_anthem.py12
-rw-r--r--bot/exts/pride/pride_facts.py13
3 files changed, 10 insertions, 27 deletions
diff --git a/bot/exts/pride/drag_queen_name.py b/bot/exts/pride/drag_queen_name.py
index 81eeaff5..15ca6576 100644
--- a/bot/exts/pride/drag_queen_name.py
+++ b/bot/exts/pride/drag_queen_name.py
@@ -9,22 +9,16 @@ from bot.bot import Bot
log = logging.getLogger(__name__)
+NAMES = json.loads(Path("bot/resources/pride/drag_queen_names.json").read_text("utf8"))
+
class DragNames(commands.Cog):
"""Gives a random drag queen name!"""
- def __init__(self):
- self.names = self.load_names()
-
- @staticmethod
- def load_names() -> list:
- """Loads a list of drag queen names."""
- return json.loads(Path("bot/resources/pride/drag_queen_names.json").read_text("utf8"))
-
@commands.command(name="dragname", aliases=("dragqueenname", "queenme"))
async def dragname(self, ctx: commands.Context) -> None:
"""Sends a message with a drag queen name."""
- await ctx.send(random.choice(self.names))
+ await ctx.send(random.choice(NAMES))
def setup(bot: Bot) -> None:
diff --git a/bot/exts/pride/pride_anthem.py b/bot/exts/pride/pride_anthem.py
index ce4b06af..4650595a 100644
--- a/bot/exts/pride/pride_anthem.py
+++ b/bot/exts/pride/pride_anthem.py
@@ -10,13 +10,12 @@ from bot.bot import Bot
log = logging.getLogger(__name__)
+VIDEOS = json.loads(Path("bot/resources/pride/anthems.json").read_text("utf8"))
+
class PrideAnthem(commands.Cog):
"""Embed a random youtube video for a gay anthem!"""
- def __init__(self):
- self.anthems = self.load_vids()
-
def get_video(self, genre: Optional[str] = None) -> dict:
"""
Picks a random anthem from the list.
@@ -27,17 +26,12 @@ class PrideAnthem(commands.Cog):
if not genre:
return random.choice(self.anthems)
else:
- songs = [song for song in self.anthems if genre.casefold() in song["genre"]]
+ songs = [song for song in VIDEOS if genre.casefold() in song["genre"]]
try:
return random.choice(songs)
except IndexError:
log.info("No videos for that genre.")
- @staticmethod
- def load_vids() -> list:
- """Loads a list of videos from the resources folder as dictionaries."""
- return json.loads(Path("bot/resources/pride/anthems.json").read_text("utf8"))
-
@commands.command(name="prideanthem", aliases=("anthem", "pridesong"))
async def prideanthem(self, ctx: commands.Context, genre: str = None) -> None:
"""
diff --git a/bot/exts/pride/pride_facts.py b/bot/exts/pride/pride_facts.py
index 5bea1d32..631e2e8b 100644
--- a/bot/exts/pride/pride_facts.py
+++ b/bot/exts/pride/pride_facts.py
@@ -15,21 +15,16 @@ from bot.utils.decorators import seasonal_task
log = logging.getLogger(__name__)
+FACTS = json.loads(Path("bot/resources/pride/facts.json").read_text("utf8"))
+
class PrideFacts(commands.Cog):
"""Provides a new fact every day during the Pride season!"""
def __init__(self, bot: Bot):
self.bot = bot
- self.facts = self.load_facts()
-
self.daily_fact_task = self.bot.loop.create_task(self.send_pride_fact_daily())
- @staticmethod
- def load_facts() -> dict:
- """Loads a dictionary of years mapping to lists of facts."""
- return json.loads(Path("bot/resources/pride/facts.json").read_text("utf8"))
-
@seasonal_task(Month.JUNE)
async def send_pride_fact_daily(self) -> None:
"""Background task to post the daily pride fact every day."""
@@ -41,8 +36,8 @@ class PrideFacts(commands.Cog):
async def send_random_fact(self, ctx: commands.Context) -> None:
"""Provides a fact from any previous day, or today."""
now = datetime.utcnow()
- previous_years_facts = (y for x, y in self.facts.items() if int(x) < now.year)
- current_year_facts = self.facts.get(str(now.year), [])[:now.day]
+ previous_years_facts = (y for x, y in FACTS.items() if int(x) < now.year)
+ current_year_facts = FACTS.get(str(now.year), [])[:now.day]
previous_facts = current_year_facts + [x for y in previous_years_facts for x in y]
try:
await ctx.send(embed=self.make_embed(random.choice(previous_facts)))