diff options
Diffstat (limited to 'bot/exts/holidays/halloween')
| -rw-r--r-- | bot/exts/holidays/halloween/candy_collection.py | 15 | ||||
| -rw-r--r-- | bot/exts/holidays/halloween/eight_ball.py (renamed from bot/exts/holidays/halloween/8ball.py) | 0 | ||||
| -rw-r--r-- | bot/exts/holidays/halloween/monstersurvey.py | 4 | ||||
| -rw-r--r-- | bot/exts/holidays/halloween/spookynamerate.py | 19 |
4 files changed, 16 insertions, 22 deletions
diff --git a/bot/exts/holidays/halloween/candy_collection.py b/bot/exts/holidays/halloween/candy_collection.py index 683114f9..ca68888b 100644 --- a/bot/exts/holidays/halloween/candy_collection.py +++ b/bot/exts/holidays/halloween/candy_collection.py @@ -1,6 +1,5 @@ import logging import random -from typing import Union import discord from async_rediscache import RedisCache @@ -18,17 +17,17 @@ ADD_CANDY_EXISTING_REACTION_CHANCE = 10 # 10% ADD_SKULL_REACTION_CHANCE = 50 # 2% ADD_SKULL_EXISTING_REACTION_CHANCE = 20 # 5% -EMOJIS = dict( - CANDY="\N{CANDY}", - SKULL="\N{SKULL}", - MEDALS=( +EMOJIS = { + "CANDY": "\N{CANDY}", + "SKULL": "\N{SKULL}", + "MEDALS": ( "\N{FIRST PLACE MEDAL}", "\N{SECOND PLACE MEDAL}", "\N{THIRD PLACE MEDAL}", "\N{SPORTS MEDAL}", "\N{SPORTS MEDAL}", ), -) +} class CandyCollection(commands.Cog): @@ -69,7 +68,7 @@ class CandyCollection(commands.Cog): @in_month(Month.OCTOBER) @commands.Cog.listener() - async def on_reaction_add(self, reaction: discord.Reaction, user: Union[discord.User, discord.Member]) -> None: + async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User | discord.Member) -> None: """Add/remove candies from a person if the reaction satisfies criteria.""" message = reaction.message # check to ensure the reactor is human @@ -140,7 +139,7 @@ class CandyCollection(commands.Cog): @staticmethod async def send_spook_msg( - author: discord.Member, channel: discord.TextChannel, candies: Union[str, int] + author: discord.Member, channel: discord.TextChannel, candies: str | int ) -> None: """Send a spooky message.""" e = discord.Embed(colour=author.colour) diff --git a/bot/exts/holidays/halloween/8ball.py b/bot/exts/holidays/halloween/eight_ball.py index 21b55a01..21b55a01 100644 --- a/bot/exts/holidays/halloween/8ball.py +++ b/bot/exts/holidays/halloween/eight_ball.py diff --git a/bot/exts/holidays/halloween/monstersurvey.py b/bot/exts/holidays/halloween/monstersurvey.py index 517f1bcb..d129f3cc 100644 --- a/bot/exts/holidays/halloween/monstersurvey.py +++ b/bot/exts/holidays/halloween/monstersurvey.py @@ -9,8 +9,8 @@ from discord.ext.commands import Bot, Cog, Context log = logging.getLogger(__name__) EMOJIS = { - "SUCCESS": u"\u2705", - "ERROR": u"\u274C" + "SUCCESS": "\u2705", + "ERROR": "\u274C" } diff --git a/bot/exts/holidays/halloween/spookynamerate.py b/bot/exts/holidays/halloween/spookynamerate.py index a76e5e12..78e8be8e 100644 --- a/bot/exts/holidays/halloween/spookynamerate.py +++ b/bot/exts/holidays/halloween/spookynamerate.py @@ -2,11 +2,10 @@ import asyncio import json import random from collections import defaultdict -from datetime import datetime, timedelta +from datetime import UTC, datetime, timedelta from logging import getLogger from os import getenv from pathlib import Path -from typing import Optional from async_rediscache import RedisCache from discord import Embed, Reaction, TextChannel, User @@ -146,7 +145,7 @@ class SpookyNameRate(Cog): ) return - elif data["name"] == name: + if data["name"] == name: await ctx.send("TOO LATE. Someone has already added this name.") return @@ -261,12 +260,8 @@ class SpookyNameRate(Cog): winners = [] for i, winner in enumerate(winner_messages): winners.append(winner) - if len(winner_messages) > i + 1: - if winner_messages[i + 1][1]["score"] != winner[1]["score"]: - break - elif len(winner_messages) == (i + 1) + 1: # The next element is the last element - if winner_messages[i + 1][1]["score"] != winner[1]["score"]: - break + if len(winner_messages) > i + 1 and winner_messages[i + 1][1]["score"] != winner[1]["score"]: + break # one iteration is complete await channel.send("Today's Spooky Name Rate Game ends now, and the winner(s) is(are)...") @@ -313,7 +308,7 @@ class SpookyNameRate(Cog): if SpookyNameRate.debug: return - now = datetime.utcnow() + now = datetime.now(tz=UTC) if now.hour < 12: twelve_pm = now.replace(hour=12, minute=0, second=0, microsecond=0) time_left = twelve_pm - now @@ -353,7 +348,7 @@ class SpookyNameRate(Cog): return embed - async def get_channel(self) -> Optional[TextChannel]: + async def get_channel(self) -> TextChannel | None: """Gets the sir-lancebot-channel after waiting until ready.""" channel = self.bot.get_channel( Channels.sir_lancebot_playground @@ -369,7 +364,7 @@ class SpookyNameRate(Cog): return True if not Client.month_override: - return datetime.utcnow().month == Month.OCTOBER + return datetime.now(tz=UTC).month == Month.OCTOBER return Client.month_override == Month.OCTOBER def cog_check(self, ctx: Context) -> bool: |