diff options
| author | 2021-05-04 12:57:03 -0400 | |
|---|---|---|
| committer | 2021-05-04 12:57:03 -0400 | |
| commit | a6cc40ff3b323dff112d7f8c339e124f3a6d9980 (patch) | |
| tree | f0cdec46d302cfc629fe9277df5cfbe6251a861b /bot/exts/christmas | |
| parent | chore: Don't return a Message object when the return annotation is None (diff) | |
chore: Prefer double quotes over single quotes
Diffstat (limited to 'bot/exts/christmas')
| -rw-r--r-- | bot/exts/christmas/advent_of_code/_helpers.py | 8 | ||||
| -rw-r--r-- | bot/exts/christmas/hanukkah_embed.py | 28 |
2 files changed, 18 insertions, 18 deletions
diff --git a/bot/exts/christmas/advent_of_code/_helpers.py b/bot/exts/christmas/advent_of_code/_helpers.py index a16a4871..f4a258c0 100644 --- a/bot/exts/christmas/advent_of_code/_helpers.py +++ b/bot/exts/christmas/advent_of_code/_helpers.py @@ -108,7 +108,7 @@ def _parse_raw_leaderboard_data(raw_leaderboard_data: dict) -> dict: # star view. We need that per star view to compute rank scores per star. for member in raw_leaderboard_data.values(): name = member["name"] if member["name"] else f"Anonymous #{member['id']}" - member_id = member['id'] + member_id = member["id"] leaderboard[member_id] = {"name": name, "score": 0, "star_1": 0, "star_2": 0} # Iterate over all days for this participant @@ -119,7 +119,7 @@ def _parse_raw_leaderboard_data(raw_leaderboard_data: dict) -> dict: leaderboard[member_id][f"star_{star}"] += 1 # Record completion datetime for this participant for this day/star - completion_time = datetime.datetime.fromtimestamp(int(data['get_star_ts'])) + completion_time = datetime.datetime.fromtimestamp(int(data["get_star_ts"])) star_results[(day, star)].append( StarResult(member_id=member_id, completion_time=completion_time) ) @@ -133,7 +133,7 @@ def _parse_raw_leaderboard_data(raw_leaderboard_data: dict) -> dict: if day in AdventOfCode.ignored_days: continue - sorted_result = sorted(results, key=operator.attrgetter('completion_time')) + sorted_result = sorted(results, key=operator.attrgetter("completion_time")) for rank, star_result in enumerate(sorted_result): leaderboard[star_result.member_id]["score"] += max_score - rank @@ -307,7 +307,7 @@ async def fetch_leaderboard(invalidate_cache: bool = False) -> dict: def get_summary_embed(leaderboard: dict) -> discord.Embed: """Get an embed with the current summary stats of the leaderboard.""" - leaderboard_url = leaderboard['full_leaderboard_url'] + leaderboard_url = leaderboard["full_leaderboard_url"] refresh_minutes = AdventOfCode.leaderboard_cache_expiry_seconds // 60 aoc_embed = discord.Embed( diff --git a/bot/exts/christmas/hanukkah_embed.py b/bot/exts/christmas/hanukkah_embed.py index cd8a9192..32002f76 100644 --- a/bot/exts/christmas/hanukkah_embed.py +++ b/bot/exts/christmas/hanukkah_embed.py @@ -28,15 +28,15 @@ class HanukkahEmbed(commands.Cog): hanukkah_dates = [] async with self.bot.http_session.get(self.url) as response: json_data = await response.json() - festivals = json_data['items'] + festivals = json_data["items"] for festival in festivals: - if festival['title'].startswith('Chanukah'): - date = festival['date'] + if festival["title"].startswith("Chanukah"): + date = festival["date"] hanukkah_dates.append(date) return hanukkah_dates @in_month(Month.DECEMBER) - @commands.command(name='hanukkah', aliases=['chanukah']) + @commands.command(name="hanukkah", aliases=["chanukah"]) async def hanukkah_festival(self, ctx: commands.Context) -> None: """Tells you about the Hanukkah Festivaltime of festival, festival day, etc).""" hanukkah_dates = await self.get_hanukkah_dates() @@ -56,7 +56,7 @@ class HanukkahEmbed(commands.Cog): month = str(today.month) year = str(today.year) embed = Embed() - embed.title = 'Hanukkah' + embed.title = "Hanukkah" embed.colour = Colours.blue if day in self.hanukkah_days and month in self.hanukkah_months and year in self.hanukkah_years: if int(day) == hanukkah_start_day: @@ -69,13 +69,13 @@ class HanukkahEmbed(commands.Cog): 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 !') + embed.description = (f"It is the starting day of Hanukkah ! " + f"Its been {hours-hanukkah_start_hour} hours hanukkah started !") await ctx.send(embed=embed) return festival_day = self.hanukkah_days.index(day) - number_suffixes = ['st', 'nd', 'rd', 'th'] - suffix = '' + number_suffixes = ["st", "nd", "rd", "th"] + suffix = "" if int(festival_day) == 1: suffix = number_suffixes[0] if int(festival_day) == 2: @@ -84,19 +84,19 @@ class HanukkahEmbed(commands.Cog): suffix = number_suffixes[2] if int(festival_day) > 3: suffix = number_suffixes[3] - message = '' + message = "" for _ in range(1, festival_day + 1): - message += ':menorah:' - embed.description = f'It is the {festival_day}{suffix} day of Hanukkah ! \n {message}' + message += ":menorah:" + embed.description = f"It is the {festival_day}{suffix} day of Hanukkah ! \n {message}" await ctx.send(embed=embed) else: if today < hanukkah_start: - festival_starting_month = hanukkah_start.strftime('%B') + festival_starting_month = hanukkah_start.strftime("%B") embed.description = (f"Hanukkah has not started yet. " f"Hanukkah will start at sundown on {hanukkah_start_day}th " f"of {festival_starting_month}.") else: - festival_end_month = hanukkah_end.strftime('%B') + festival_end_month = hanukkah_end.strftime("%B") embed.description = (f"Looks like you missed Hanukkah !" f"Hanukkah ended on {hanukkah_end_day}th of {festival_end_month}.") |