aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/holidays/easter
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/holidays/easter')
-rw-r--r--bot/exts/holidays/easter/bunny_name_generator.py8
-rw-r--r--bot/exts/holidays/easter/earth_photos.py2
-rw-r--r--bot/exts/holidays/easter/easter_riddle.py2
-rw-r--r--bot/exts/holidays/easter/egg_decorating.py15
-rw-r--r--bot/exts/holidays/easter/egghead_quiz.py13
5 files changed, 20 insertions, 20 deletions
diff --git a/bot/exts/holidays/easter/bunny_name_generator.py b/bot/exts/holidays/easter/bunny_name_generator.py
index 50872ebc..3034da4a 100644
--- a/bot/exts/holidays/easter/bunny_name_generator.py
+++ b/bot/exts/holidays/easter/bunny_name_generator.py
@@ -3,7 +3,6 @@ import logging
import random
import re
from pathlib import Path
-from typing import Optional
from discord.ext import commands
@@ -18,7 +17,7 @@ class BunnyNameGenerator(commands.Cog):
"""Generate a random bunny name, or bunnify your Discord username!"""
@staticmethod
- def find_separators(displayname: str) -> Optional[list[str]]:
+ def find_separators(displayname: str) -> list[str] | None:
"""Check if Discord name contains spaces so we can bunnify an individual word in the name."""
new_name = re.split(r"[_.\s]", displayname)
if displayname not in new_name:
@@ -26,7 +25,7 @@ class BunnyNameGenerator(commands.Cog):
return None
@staticmethod
- def find_vowels(displayname: str) -> Optional[str]:
+ def find_vowels(displayname: str) -> str | None:
"""
Finds vowels in the user's display name.
@@ -46,6 +45,7 @@ class BunnyNameGenerator(commands.Cog):
new_name = re.sub(exp, vowel_sub, displayname)
if new_name != displayname:
return new_name
+ return None
@staticmethod
def append_name(displayname: str) -> str:
@@ -77,7 +77,7 @@ class BunnyNameGenerator(commands.Cog):
unmatched_name = self.append_name(username)
if spaces_in_name is not None:
- replacements = ["Cotton", "Fluff", "Floof" "Bounce", "Snuffle", "Nibble", "Cuddle", "Velvetpaw", "Carrot"]
+ replacements = ["Cotton", "Fluff", "Floof", "Bounce", "Snuffle", "Nibble", "Cuddle", "Velvetpaw", "Carrot"]
word_to_replace = random.choice(spaces_in_name)
substitute = random.choice(replacements)
bunnified_name = username.replace(word_to_replace, substitute)
diff --git a/bot/exts/holidays/easter/earth_photos.py b/bot/exts/holidays/easter/earth_photos.py
index 013122c8..66f1b07b 100644
--- a/bot/exts/holidays/easter/earth_photos.py
+++ b/bot/exts/holidays/easter/earth_photos.py
@@ -12,7 +12,7 @@ API_URL = "https://api.unsplash.com/photos/random"
class EarthPhotos(commands.Cog):
- """This cog contains the command for earth photos."""
+ """The earth photos cog."""
def __init__(self, bot: Bot):
self.bot = bot
diff --git a/bot/exts/holidays/easter/easter_riddle.py b/bot/exts/holidays/easter/easter_riddle.py
index c5d7b164..6c29dd17 100644
--- a/bot/exts/holidays/easter/easter_riddle.py
+++ b/bot/exts/holidays/easter/easter_riddle.py
@@ -18,7 +18,7 @@ TIMELIMIT = 10
class EasterRiddle(commands.Cog):
- """This cog contains the command for the Easter quiz!"""
+ """The Easter quiz cog."""
def __init__(self, bot: Bot):
self.bot = bot
diff --git a/bot/exts/holidays/easter/egg_decorating.py b/bot/exts/holidays/easter/egg_decorating.py
index a9334820..1327f4d0 100644
--- a/bot/exts/holidays/easter/egg_decorating.py
+++ b/bot/exts/holidays/easter/egg_decorating.py
@@ -4,7 +4,6 @@ import random
from contextlib import suppress
from io import BytesIO
from pathlib import Path
-from typing import Optional, Union
import discord
from PIL import Image
@@ -33,7 +32,7 @@ class EggDecorating(commands.Cog):
"""Decorate some easter eggs!"""
@staticmethod
- def replace_invalid(colour: str) -> Optional[int]:
+ def replace_invalid(colour: str) -> int | None:
"""Attempts to match with HTML or XKCD colour names, returning the int value."""
with suppress(KeyError):
return int(HTML_COLOURS[colour], 16)
@@ -43,8 +42,8 @@ class EggDecorating(commands.Cog):
@commands.command(aliases=("decorateegg",))
async def eggdecorate(
- self, ctx: commands.Context, *colours: Union[discord.Colour, str]
- ) -> Optional[Image.Image]:
+ self, ctx: commands.Context, *colours: discord.Colour | str
+ ) -> Image.Image | None:
"""
Picks a random egg design and decorates it using the given colours.
@@ -53,7 +52,7 @@ class EggDecorating(commands.Cog):
"""
if len(colours) < 2:
await ctx.send("You must include at least 2 colours!")
- return
+ return None
invalid = []
colours = list(colours)
@@ -68,10 +67,10 @@ class EggDecorating(commands.Cog):
if len(invalid) > 1:
await ctx.send(f"Sorry, I don't know these colours: {' '.join(invalid)}")
- return
- elif len(invalid) == 1:
+ return None
+ if len(invalid) == 1:
await ctx.send(f"Sorry, I don't know the colour {invalid[0]}!")
- return
+ return None
async with ctx.typing():
# Expand list to 8 colours
diff --git a/bot/exts/holidays/easter/egghead_quiz.py b/bot/exts/holidays/easter/egghead_quiz.py
index 2e4d1931..046f9fac 100644
--- a/bot/exts/holidays/easter/egghead_quiz.py
+++ b/bot/exts/holidays/easter/egghead_quiz.py
@@ -3,7 +3,6 @@ import logging
import random
from json import loads
from pathlib import Path
-from typing import Union
import discord
from discord.ext import commands
@@ -29,7 +28,7 @@ TIMELIMIT = 30
class EggheadQuiz(commands.Cog):
- """This cog contains the command for the Easter quiz!"""
+ """The Egghead quiz cog."""
def __init__(self):
self.quiz_messages = {}
@@ -117,9 +116,10 @@ class EggheadQuiz(commands.Cog):
)
await ctx.send(content, embed=a_embed)
+ return None
@staticmethod
- async def already_reacted(new_reaction: discord.Reaction, user: Union[discord.Member, discord.User]) -> bool:
+ async def already_reacted(new_reaction: discord.Reaction, user: discord.Member | discord.User) -> bool:
"""Returns whether a given user has reacted more than once to a given message."""
message = new_reaction.message
for reaction in message.reactions:
@@ -131,16 +131,17 @@ class EggheadQuiz(commands.Cog):
return False
@commands.Cog.listener()
- async def on_reaction_add(self, reaction: discord.Reaction, user: Union[discord.Member, discord.User]) -> None:
+ async def on_reaction_add(self, reaction: discord.Reaction, user: discord.Member | discord.User) -> None:
"""Listener to listen specifically for reactions of quiz messages."""
if user.bot:
- return
+ return None
if reaction.message.id not in self.quiz_messages:
- return
+ return None
if str(reaction.emoji) not in self.quiz_messages[reaction.message.id]:
return await reaction.message.remove_reaction(reaction, user)
if await self.already_reacted(reaction, user):
return await reaction.message.remove_reaction(reaction, user)
+ return None
async def setup(bot: Bot) -> None: