diff options
Diffstat (limited to 'bot/exts')
| -rw-r--r-- | bot/exts/christmas/advent_of_code/_cog.py | 4 | ||||
| -rw-r--r-- | bot/exts/christmas/hanukkah_embed.py | 16 | ||||
| -rw-r--r-- | bot/exts/pride/drag_queen_name.py | 9 | ||||
| -rw-r--r-- | bot/exts/pride/pride_anthem.py | 14 | ||||
| -rw-r--r-- | bot/exts/pride/pride_facts.py | 18 | 
5 files changed, 32 insertions, 29 deletions
| diff --git a/bot/exts/christmas/advent_of_code/_cog.py b/bot/exts/christmas/advent_of_code/_cog.py index 8376987d..da1cf28d 100644 --- a/bot/exts/christmas/advent_of_code/_cog.py +++ b/bot/exts/christmas/advent_of_code/_cog.py @@ -124,7 +124,7 @@ class AdventOfCode(commands.Cog):      @whitelist_override(channels=AOC_WHITELIST)      async def about_aoc(self, ctx: commands.Context) -> None:          """Respond with an explanation of all things Advent of Code.""" -        await ctx.send("", embed=self.cached_about_aoc) +        await ctx.send(embed=self.cached_about_aoc)      @adventofcode_group.command(name="join", aliases=("j",), brief="Learn how to join the leaderboard (via DM)")      @whitelist_override(channels=AOC_WHITELIST) @@ -135,7 +135,7 @@ class AdventOfCode(commands.Cog):              await ctx.send(f"The Python Discord leaderboard for {current_year} is not yet available!")              return -        author = ctx.message.author +        author = ctx.author          log.info(f"{author.name} ({author.id}) has requested a PyDis AoC leaderboard code")          if AocConfig.staff_leaderboard_id and any(r.id == Roles.helpers for r in author.roles): diff --git a/bot/exts/christmas/hanukkah_embed.py b/bot/exts/christmas/hanukkah_embed.py index 4f470a34..cd8a9192 100644 --- a/bot/exts/christmas/hanukkah_embed.py +++ b/bot/exts/christmas/hanukkah_embed.py @@ -5,6 +5,7 @@ from typing import List  from discord import Embed  from discord.ext import commands +from bot.bot import Bot  from bot.constants import Colours, Month  from bot.utils.decorators import in_month @@ -14,7 +15,7 @@ log = logging.getLogger(__name__)  class HanukkahEmbed(commands.Cog):      """A cog that returns information about Hanukkah festival.""" -    def __init__(self, bot: commands.Bot): +    def __init__(self, bot: Bot):          self.bot = bot          self.url = ("https://www.hebcal.com/hebcal/?v=1&cfg=json&maj=on&min=on&mod=on&nx=on&"                      "year=now&month=x&ss=on&mf=on&c=on&geo=geoname&geonameid=3448439&m=50&s=on") @@ -60,17 +61,18 @@ class HanukkahEmbed(commands.Cog):          if day in self.hanukkah_days and month in self.hanukkah_months and year in self.hanukkah_years:              if int(day) == hanukkah_start_day:                  now = datetime.datetime.utcnow() -                now = str(now) -                hours = int(now[11:13]) + 4  # using only hours +                hours = now.hour + 4  # using only hours                  hanukkah_start_hour = 18                  if hours < hanukkah_start_hour:                      embed.description = (f"Hanukkah hasnt started yet, "                                           f"it will start in about {hanukkah_start_hour-hours} hour/s.") -                    return await ctx.send(embed=embed) +                    await ctx.send(embed=embed) +                    return                  elif hours > hanukkah_start_hour:                      embed.description = (f'It is the starting day of Hanukkah ! '                                           f'Its been {hours-hanukkah_start_hour} hours hanukkah started !') -                    return await ctx.send(embed=embed) +                    await ctx.send(embed=embed) +                    return              festival_day = self.hanukkah_days.index(day)              number_suffixes = ['st', 'nd', 'rd', 'th']              suffix = '' @@ -108,6 +110,6 @@ class HanukkahEmbed(commands.Cog):              self.hanukkah_years.append(date[0:4]) -def setup(bot: commands.Bot) -> None: -    """Cog load.""" +def setup(bot: Bot) -> None: +    """Load the Hanukkah Embed Cog."""      bot.add_cog(HanukkahEmbed(bot)) diff --git a/bot/exts/pride/drag_queen_name.py b/bot/exts/pride/drag_queen_name.py index fca9750f..32ead1bc 100644 --- a/bot/exts/pride/drag_queen_name.py +++ b/bot/exts/pride/drag_queen_name.py @@ -5,14 +5,15 @@ from pathlib import Path  from discord.ext import commands +from bot.bot import Bot +  log = logging.getLogger(__name__)  class DragNames(commands.Cog):      """Gives a random drag queen name!""" -    def __init__(self, bot: commands.Bot): -        self.bot = bot +    def __init__(self):          self.names = self.load_names()      @staticmethod @@ -27,6 +28,6 @@ class DragNames(commands.Cog):          await ctx.send(random.choice(self.names)) -def setup(bot: commands.Bot) -> None: -    """Cog loader for drag queen name generator.""" +def setup(bot: Bot) -> None: +    """Load the Drag Queen Cog."""      bot.add_cog(DragNames(bot)) diff --git a/bot/exts/pride/pride_anthem.py b/bot/exts/pride/pride_anthem.py index 33cb2a9d..a7f8d7ef 100644 --- a/bot/exts/pride/pride_anthem.py +++ b/bot/exts/pride/pride_anthem.py @@ -2,20 +2,22 @@ import json  import logging  import random  from pathlib import Path +from typing import Optional  from discord.ext import commands +from bot.bot import Bot +  log = logging.getLogger(__name__)  class PrideAnthem(commands.Cog):      """Embed a random youtube video for a gay anthem!""" -    def __init__(self, bot: commands.Bot): -        self.bot = bot +    def __init__(self):          self.anthems = self.load_vids() -    def get_video(self, genre: str = None) -> dict: +    def get_video(self, genre: Optional[str] = None) -> dict:          """          Picks a random anthem from the list. @@ -52,6 +54,6 @@ class PrideAnthem(commands.Cog):              await ctx.send("I couldn't find a video, sorry!") -def setup(bot: commands.Bot) -> None: -    """Cog loader for pride anthem.""" -    bot.add_cog(PrideAnthem(bot)) +def setup(bot: Bot) -> None: +    """Load the Pride Anthem Cog.""" +    bot.add_cog(PrideAnthem()) diff --git a/bot/exts/pride/pride_facts.py b/bot/exts/pride/pride_facts.py index 5bd5d0ce..b2daaab7 100644 --- a/bot/exts/pride/pride_facts.py +++ b/bot/exts/pride/pride_facts.py @@ -15,8 +15,6 @@ from bot.utils.decorators import seasonal_task  log = logging.getLogger(__name__) -Sendable = Union[commands.Context, discord.TextChannel] -  class PrideFacts(commands.Cog):      """Provides a new fact every day during the Pride season!""" @@ -44,7 +42,7 @@ 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 = (self.facts[x] for x in self.facts.keys() if int(x) < now.year) +        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_facts = current_year_facts + [x for y in previous_years_facts for x in y]          try: @@ -52,7 +50,7 @@ class PrideFacts(commands.Cog):          except IndexError:              await ctx.send("No facts available") -    async def send_select_fact(self, target: Sendable, _date: Union[str, datetime]) -> None: +    async def send_select_fact(self, target: discord.abc.Messageable, _date: Union[str, datetime]) -> None:          """Provides the fact for the specified day, if the day is today, or is in the past."""          now = datetime.utcnow()          if isinstance(_date, str): @@ -76,7 +74,7 @@ class PrideFacts(commands.Cog):              await target.send("The fact for the selected day is not yet available.")      @commands.command(name="pridefact", aliases=["pridefacts"]) -    async def pridefact(self, ctx: commands.Context) -> None: +    async def pridefact(self, ctx: commands.Context, option: str = None) -> None:          """          Sends a message with a pride fact of the day. @@ -85,15 +83,15 @@ class PrideFacts(commands.Cog):          If a date is given as an argument, and the date is in the past, the fact from that day          will be provided.          """ -        message_body = ctx.message.content[len(ctx.invoked_with) + 2:] -        if message_body == "": +        if not option:              await self.send_select_fact(ctx, datetime.utcnow()) -        elif message_body.lower().startswith("rand"): +        elif option.lower().startswith("rand"):              await self.send_random_fact(ctx)          else: -            await self.send_select_fact(ctx, message_body) +            await self.send_select_fact(ctx, option) -    def make_embed(self, fact: str) -> discord.Embed: +    @staticmethod +    def make_embed(fact: str) -> discord.Embed:          """Makes a nice embed for the fact to be sent."""          return discord.Embed(              colour=Colours.pink, | 
