aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/easter
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/easter')
-rw-r--r--bot/exts/easter/april_fools_vids.py10
-rw-r--r--bot/exts/easter/bunny_name_generator.py27
-rw-r--r--bot/exts/easter/earth_photos.py7
-rw-r--r--bot/exts/easter/easter_riddle.py8
-rw-r--r--bot/exts/easter/egg_decorating.py19
-rw-r--r--bot/exts/easter/egg_facts.py4
-rw-r--r--bot/exts/easter/egghead_quiz.py22
-rw-r--r--bot/exts/easter/save_the_planet.py14
-rw-r--r--bot/exts/easter/traditions.py13
9 files changed, 63 insertions, 61 deletions
diff --git a/bot/exts/easter/april_fools_vids.py b/bot/exts/easter/april_fools_vids.py
index c7a3c014..3ce1f72a 100644
--- a/bot/exts/easter/april_fools_vids.py
+++ b/bot/exts/easter/april_fools_vids.py
@@ -4,6 +4,8 @@ from json import load
from discord.ext import commands
+from bot.bot import Bot
+
log = logging.getLogger(__name__)
with open("bot/resources/easter/april_fools_vids.json", encoding="utf-8") as f:
@@ -13,7 +15,7 @@ with open("bot/resources/easter/april_fools_vids.json", encoding="utf-8") as f:
class AprilFoolVideos(commands.Cog):
"""A cog for April Fools' that gets a random April Fools' video from Youtube."""
- @commands.command(name='fool')
+ @commands.command(name="fool")
async def april_fools(self, ctx: commands.Context) -> None:
"""Get a random April Fools' video from Youtube."""
video = random.choice(ALL_VIDS)
@@ -23,6 +25,6 @@ class AprilFoolVideos(commands.Cog):
await ctx.send(f"Check out this April Fools' video by {channel}.\n\n{url}")
-def setup(bot: commands.Bot) -> None:
- """April Fools' Cog load."""
- bot.add_cog(AprilFoolVideos(bot))
+def setup(bot: Bot) -> None:
+ """Load the April Fools' Cog."""
+ bot.add_cog(AprilFoolVideos())
diff --git a/bot/exts/easter/bunny_name_generator.py b/bot/exts/easter/bunny_name_generator.py
index 3ecf9be9..19a0b0f6 100644
--- a/bot/exts/easter/bunny_name_generator.py
+++ b/bot/exts/easter/bunny_name_generator.py
@@ -7,6 +7,8 @@ from typing import List, Union
from discord.ext import commands
+from bot.bot import Bot
+
log = logging.getLogger(__name__)
with Path("bot/resources/easter/bunny_names.json").open("r", encoding="utf8") as f:
@@ -16,12 +18,9 @@ with Path("bot/resources/easter/bunny_names.json").open("r", encoding="utf8") as
class BunnyNameGenerator(commands.Cog):
"""Generate a random bunny name, or bunnify your Discord username!"""
- def __init__(self, bot: commands.Bot):
- self.bot = bot
-
def find_separators(self, displayname: str) -> Union[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)
+ new_name = re.split(r"[_.\s]", displayname)
if displayname not in new_name:
return new_name
@@ -34,11 +33,11 @@ class BunnyNameGenerator(commands.Cog):
Only the most recently matched pattern will apply the changes.
"""
expressions = [
- (r'a.+y', 'patchy'),
- (r'e.+y', 'ears'),
- (r'i.+y', 'ditsy'),
- (r'o.+y', 'oofy'),
- (r'u.+y', 'uffy'),
+ ("a.+y", "patchy"),
+ ("e.+y", "ears"),
+ ("i.+y", "ditsy"),
+ ("o.+y", "oofy"),
+ ("u.+y", "uffy"),
]
for exp, vowel_sub in expressions:
@@ -48,7 +47,7 @@ class BunnyNameGenerator(commands.Cog):
def append_name(self, displayname: str) -> str:
"""Adds a suffix to the end of the Discord name."""
- extensions = ['foot', 'ear', 'nose', 'tail']
+ extensions = ["foot", "ear", "nose", "tail"]
suffix = random.choice(extensions)
appended_name = displayname + suffix
@@ -75,7 +74,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)
@@ -87,6 +86,6 @@ class BunnyNameGenerator(commands.Cog):
await ctx.send(bunnified_name)
-def setup(bot: commands.Bot) -> None:
- """Bunny Name Generator Cog load."""
- bot.add_cog(BunnyNameGenerator(bot))
+def setup(bot: Bot) -> None:
+ """Load the Bunny Name Generator Cog."""
+ bot.add_cog(BunnyNameGenerator())
diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py
index bf658391..0e82e99a 100644
--- a/bot/exts/easter/earth_photos.py
+++ b/bot/exts/easter/earth_photos.py
@@ -3,6 +3,7 @@ import logging
import discord
from discord.ext import commands
+from bot.bot import Bot
from bot.constants import Colours
from bot.constants import Tokens
@@ -12,7 +13,7 @@ log = logging.getLogger(__name__)
class EarthPhotos(commands.Cog):
"""This cog contains the command for earth photos."""
- def __init__(self, bot: commands.Bot):
+ def __init__(self, bot: Bot):
self.bot = bot
@commands.command(aliases=["earth"])
@@ -20,7 +21,7 @@ class EarthPhotos(commands.Cog):
"""Returns a random photo of earth, sourced from Unsplash."""
async with ctx.typing():
async with self.bot.http_session.get(
- 'https://api.unsplash.com/photos/random',
+ "https://api.unsplash.com/photos/random",
params={"query": "planet_earth", "client_id": Tokens.unsplash_access_key}
) as r:
jsondata = await r.json()
@@ -55,7 +56,7 @@ class EarthPhotos(commands.Cog):
await ctx.send(embed=embed)
-def setup(bot: commands.Bot) -> None:
+def setup(bot: Bot) -> None:
"""Load the Earth Photos cog."""
if not Tokens.unsplash_access_key:
log.warning("No Unsplash access key found. Cog not loading.")
diff --git a/bot/exts/easter/easter_riddle.py b/bot/exts/easter/easter_riddle.py
index a93b3745..9a253a6a 100644
--- a/bot/exts/easter/easter_riddle.py
+++ b/bot/exts/easter/easter_riddle.py
@@ -7,6 +7,7 @@ from pathlib import Path
import discord
from discord.ext import commands
+from bot.bot import Bot
from bot.constants import Colours, NEGATIVE_REPLIES
log = logging.getLogger(__name__)
@@ -20,7 +21,7 @@ TIMELIMIT = 10
class EasterRiddle(commands.Cog):
"""This cog contains the command for the Easter quiz!"""
- def __init__(self, bot: commands.Bot):
+ def __init__(self, bot: Bot):
self.bot = bot
self.winners = set()
self.correct = ""
@@ -34,7 +35,8 @@ class EasterRiddle(commands.Cog):
The duration of the hint interval can be configured by changing the TIMELIMIT constant in this file.
"""
if self.current_channel:
- return await ctx.send(f"A riddle is already being solved in {self.current_channel.mention}!")
+ await ctx.send(f"A riddle is already being solved in {self.current_channel.mention}!")
+ return
# Don't let users start in a DM
if not ctx.guild:
@@ -106,6 +108,6 @@ class EasterRiddle(commands.Cog):
self.winners.add(message.author.mention)
-def setup(bot: commands.Bot) -> None:
+def setup(bot: Bot) -> None:
"""Easter Riddle Cog load."""
bot.add_cog(EasterRiddle(bot))
diff --git a/bot/exts/easter/egg_decorating.py b/bot/exts/easter/egg_decorating.py
index a847388d..3744989d 100644
--- a/bot/exts/easter/egg_decorating.py
+++ b/bot/exts/easter/egg_decorating.py
@@ -10,6 +10,7 @@ import discord
from PIL import Image
from discord.ext import commands
+from bot.bot import Bot
from bot.utils import helpers
log = logging.getLogger(__name__)
@@ -33,9 +34,6 @@ IRREPLACEABLE = [
class EggDecorating(commands.Cog):
"""Decorate some easter eggs!"""
- def __init__(self, bot: commands.Bot) -> None:
- self.bot = bot
-
@staticmethod
def replace_invalid(colour: str) -> Union[int, None]:
"""Attempts to match with HTML or XKCD colour names, returning the int value."""
@@ -56,7 +54,8 @@ class EggDecorating(commands.Cog):
Discord colour names, HTML colour names, XKCD colour names and hex values are accepted.
"""
if len(colours) < 2:
- return await ctx.send("You must include at least 2 colours!")
+ await ctx.send("You must include at least 2 colours!")
+ return
invalid = []
colours = list(colours)
@@ -70,9 +69,11 @@ class EggDecorating(commands.Cog):
invalid.append(helpers.suppress_links(colour))
if len(invalid) > 1:
- return await ctx.send(f"Sorry, I don't know these colours: {' '.join(invalid)}")
+ await ctx.send(f"Sorry, I don't know these colours: {' '.join(invalid)}")
+ return
elif len(invalid) == 1:
- return await ctx.send(f"Sorry, I don't know the colour {invalid[0]}!")
+ await ctx.send(f"Sorry, I don't know the colour {invalid[0]}!")
+ return
async with ctx.typing():
# Expand list to 8 colours
@@ -115,6 +116,6 @@ class EggDecorating(commands.Cog):
return new_im
-def setup(bot: commands.bot) -> None:
- """Egg decorating Cog load."""
- bot.add_cog(EggDecorating(bot))
+def setup(bot: Bot) -> None:
+ """Load the Egg decorating Cog."""
+ bot.add_cog(EggDecorating())
diff --git a/bot/exts/easter/egg_facts.py b/bot/exts/easter/egg_facts.py
index 761e9059..8c93ca7b 100644
--- a/bot/exts/easter/egg_facts.py
+++ b/bot/exts/easter/egg_facts.py
@@ -41,7 +41,7 @@ class EasterFacts(commands.Cog):
channel = self.bot.get_channel(Channels.community_bot_commands)
await channel.send(embed=self.make_embed())
- @commands.command(name='eggfact', aliases=['fact'])
+ @commands.command(name="eggfact", aliases=["fact"])
async def easter_facts(self, ctx: commands.Context) -> None:
"""Get easter egg facts."""
embed = self.make_embed()
@@ -57,5 +57,5 @@ class EasterFacts(commands.Cog):
def setup(bot: Bot) -> None:
- """Easter Egg facts cog load."""
+ """Load the Easter Egg facts Cog."""
bot.add_cog(EasterFacts(bot))
diff --git a/bot/exts/easter/egghead_quiz.py b/bot/exts/easter/egghead_quiz.py
index 0498d9db..59c1f6f8 100644
--- a/bot/exts/easter/egghead_quiz.py
+++ b/bot/exts/easter/egghead_quiz.py
@@ -8,6 +8,7 @@ from typing import Union
import discord
from discord.ext import commands
+from bot.bot import Bot
from bot.constants import Colours
log = logging.getLogger(__name__)
@@ -17,12 +18,12 @@ with open(Path("bot/resources/easter/egghead_questions.json"), "r", encoding="ut
EMOJIS = [
- '\U0001f1e6', '\U0001f1e7', '\U0001f1e8', '\U0001f1e9', '\U0001f1ea',
- '\U0001f1eb', '\U0001f1ec', '\U0001f1ed', '\U0001f1ee', '\U0001f1ef',
- '\U0001f1f0', '\U0001f1f1', '\U0001f1f2', '\U0001f1f3', '\U0001f1f4',
- '\U0001f1f5', '\U0001f1f6', '\U0001f1f7', '\U0001f1f8', '\U0001f1f9',
- '\U0001f1fa', '\U0001f1fb', '\U0001f1fc', '\U0001f1fd', '\U0001f1fe',
- '\U0001f1ff'
+ "\U0001f1e6", "\U0001f1e7", "\U0001f1e8", "\U0001f1e9", "\U0001f1ea",
+ "\U0001f1eb", "\U0001f1ec", "\U0001f1ed", "\U0001f1ee", "\U0001f1ef",
+ "\U0001f1f0", "\U0001f1f1", "\U0001f1f2", "\U0001f1f3", "\U0001f1f4",
+ "\U0001f1f5", "\U0001f1f6", "\U0001f1f7", "\U0001f1f8", "\U0001f1f9",
+ "\U0001f1fa", "\U0001f1fb", "\U0001f1fc", "\U0001f1fd", "\U0001f1fe",
+ "\U0001f1ff"
] # Regional Indicators A-Z (used for voting)
TIMELIMIT = 30
@@ -31,8 +32,7 @@ TIMELIMIT = 30
class EggheadQuiz(commands.Cog):
"""This cog contains the command for the Easter quiz!"""
- def __init__(self, bot: commands.Bot) -> None:
- self.bot = bot
+ def __init__(self) -> None:
self.quiz_messages = {}
@commands.command(aliases=["eggheadquiz", "easterquiz"])
@@ -114,6 +114,6 @@ class EggheadQuiz(commands.Cog):
return await reaction.message.remove_reaction(reaction, user)
-def setup(bot: commands.Bot) -> None:
- """Egghead Quiz Cog load."""
- bot.add_cog(EggheadQuiz(bot))
+def setup(bot: Bot) -> None:
+ """Load the Egghead Quiz Cog."""
+ bot.add_cog(EggheadQuiz())
diff --git a/bot/exts/easter/save_the_planet.py b/bot/exts/easter/save_the_planet.py
index 8f644259..444bb030 100644
--- a/bot/exts/easter/save_the_planet.py
+++ b/bot/exts/easter/save_the_planet.py
@@ -4,26 +4,24 @@ from pathlib import Path
from discord import Embed
from discord.ext import commands
+from bot.bot import Bot
from bot.utils.randomization import RandomCycle
-with Path("bot/resources/easter/save_the_planet.json").open('r', encoding='utf8') as f:
+with Path("bot/resources/easter/save_the_planet.json").open("r", encoding="utf8") as f:
EMBED_DATA = RandomCycle(json.load(f))
class SaveThePlanet(commands.Cog):
"""A cog that teaches users how they can help our planet."""
- def __init__(self, bot: commands.Bot) -> None:
- self.bot = bot
-
- @commands.command(aliases=('savetheearth', 'saveplanet', 'saveearth'))
+ @commands.command(aliases=("savetheearth", "saveplanet", "saveearth"))
async def savetheplanet(self, ctx: commands.Context) -> None:
"""Responds with a random tip on how to be eco-friendly and help our planet."""
return_embed = Embed.from_dict(next(EMBED_DATA))
await ctx.send(embed=return_embed)
-def setup(bot: commands.Bot) -> None:
- """Save the Planet Cog load."""
- bot.add_cog(SaveThePlanet(bot))
+def setup(bot: Bot) -> None:
+ """Load the Save the Planet Cog."""
+ bot.add_cog(SaveThePlanet())
diff --git a/bot/exts/easter/traditions.py b/bot/exts/easter/traditions.py
index 85b4adfb..cb70f2d0 100644
--- a/bot/exts/easter/traditions.py
+++ b/bot/exts/easter/traditions.py
@@ -5,6 +5,8 @@ from pathlib import Path
from discord.ext import commands
+from bot.bot import Bot
+
log = logging.getLogger(__name__)
with open(Path("bot/resources/easter/traditions.json"), "r", encoding="utf8") as f:
@@ -14,10 +16,7 @@ with open(Path("bot/resources/easter/traditions.json"), "r", encoding="utf8") as
class Traditions(commands.Cog):
"""A cog which allows users to get a random easter tradition or custom from a random country."""
- def __init__(self, bot: commands.Bot):
- self.bot = bot
-
- @commands.command(aliases=('eastercustoms',))
+ @commands.command(aliases=("eastercustoms",))
async def easter_tradition(self, ctx: commands.Context) -> None:
"""Responds with a random tradition or custom."""
random_country = random.choice(list(traditions))
@@ -25,6 +24,6 @@ class Traditions(commands.Cog):
await ctx.send(f"{random_country}:\n{traditions[random_country]}")
-def setup(bot: commands.Bot) -> None:
- """Traditions Cog load."""
- bot.add_cog(Traditions(bot))
+def setup(bot: Bot) -> None:
+ """Load the Traditions Cog."""
+ bot.add_cog(Traditions())