diff options
Diffstat (limited to 'bot/seasons')
25 files changed, 91 insertions, 33 deletions
diff --git a/bot/seasons/easter/april_fools_vids.py b/bot/seasons/easter/april_fools_vids.py index c504229d..9fbe87a0 100644 --- a/bot/seasons/easter/april_fools_vids.py +++ b/bot/seasons/easter/april_fools_vids.py @@ -19,7 +19,7 @@ class AprilFoolVideos(commands.Cog): @staticmethod def load_json(): """A function to load JSON data.""" - p = Path('bot', 'resources', 'easter', 'april_fools_vids.json') + p = Path('bot/resources/easterapril_fools_vids.json') with p.open() as json_file: all_vids = load(json_file) return all_vids diff --git a/bot/seasons/easter/avatar_easterifier.py b/bot/seasons/easter/avatar_easterifier.py index 0e0b5934..ad8b5473 100644 --- a/bot/seasons/easter/avatar_easterifier.py +++ b/bot/seasons/easter/avatar_easterifier.py @@ -104,7 +104,7 @@ class AvatarEasterifier(commands.Cog): im.alpha_composite(egg, (im.width - egg.width, (im.height - egg.height)//2)) # Right centre. ctx.send = send_message # Reassigns ctx.send else: - bunny = Image.open(Path("bot", "resources", "easter", "chocolate_bunny.png")) + bunny = Image.open(Path("bot/resources/easter/chocolate_bunny.png")) im.alpha_composite(bunny, (im.width - bunny.width, (im.height - bunny.height)//2)) # Right centre. bufferedio = BytesIO() diff --git a/bot/seasons/easter/conversationstarters.py b/bot/seasons/easter/conversationstarters.py index 4432c348..c2cdf26c 100644 --- a/bot/seasons/easter/conversationstarters.py +++ b/bot/seasons/easter/conversationstarters.py @@ -7,7 +7,7 @@ from discord.ext import commands log = logging.getLogger(__name__) -with open(Path('bot', 'resources', 'easter', 'starter.json'), 'r', encoding="utf8") as f: +with open(Path("bot/resources/easter/starter.json"), "r", encoding="utf8") as f: starters = json.load(f) diff --git a/bot/seasons/easter/egg_decorating.py b/bot/seasons/easter/egg_decorating.py index 58d070bc..ee8a80e5 100644 --- a/bot/seasons/easter/egg_decorating.py +++ b/bot/seasons/easter/egg_decorating.py @@ -12,10 +12,10 @@ from discord.ext import commands log = logging.getLogger(__name__) -with open(Path("bot", "resources", "evergreen", "html_colours.json")) as f: +with open(Path("bot/resources/evergreen/html_colours.json")) as f: HTML_COLOURS = json.load(f) -with open(Path("bot", "resources", "evergreen", "xkcd_colours.json")) as f: +with open(Path("bot/resources/evergreen/xkcd_colours.json")) as f: XKCD_COLOURS = json.load(f) COLOURS = [ @@ -77,7 +77,7 @@ class EggDecorating(commands.Cog): q, r = divmod(8, colours_n) colours = colours * q + colours[:r] num = random.randint(1, 6) - im = Image.open(Path("bot", "resources", "easter", "easter_eggs", f"design{num}.png")) + im = Image.open(Path(f"bot/resources/easter/easter_eggs/design{num}.png")) data = list(im.getdata()) replaceable = {x for x in data if x not in IRREPLACEABLE} diff --git a/bot/seasons/easter/egg_hunt/cog.py b/bot/seasons/easter/egg_hunt/cog.py index 110a39f5..30fd3284 100644 --- a/bot/seasons/easter/egg_hunt/cog.py +++ b/bot/seasons/easter/egg_hunt/cog.py @@ -15,7 +15,7 @@ from .constants import Colours, EggHuntSettings, Emoji, Roles log = logging.getLogger(__name__) -DB_PATH = Path("bot", "resources", "persist", "egg_hunt.sqlite") +DB_PATH = Path("bot/resources/persist/egg_hunt.sqlite") TEAM_MAP = { Roles.white: Emoji.egg_white, diff --git a/bot/seasons/easter/egghead_quiz.py b/bot/seasons/easter/egghead_quiz.py index 7adeaebd..3e0cc598 100644 --- a/bot/seasons/easter/egghead_quiz.py +++ b/bot/seasons/easter/egghead_quiz.py @@ -11,7 +11,7 @@ from bot.constants import Colours log = logging.getLogger(__name__) -with open(Path('bot', 'resources', 'easter', 'egghead_questions.json'), 'r', encoding="utf8") as f: +with open(Path("bot/resources/easter/egghead_questions.json"), "r", encoding="utf8") as f: EGGHEAD_QUESTIONS = load(f) diff --git a/bot/seasons/easter/traditions.py b/bot/seasons/easter/traditions.py index bed874f9..f04b8828 100644 --- a/bot/seasons/easter/traditions.py +++ b/bot/seasons/easter/traditions.py @@ -7,7 +7,7 @@ from discord.ext import commands log = logging.getLogger(__name__) -with open(Path('bot', 'resources', 'easter', 'traditions.json'), 'r', encoding="utf8") as f: +with open(Path("bot/resources/easter/traditions.json"), "r", encoding="utf8") as f: traditions = json.load(f) diff --git a/bot/seasons/evergreen/magic_8ball.py b/bot/seasons/evergreen/magic_8ball.py index 9add06af..55652af7 100644 --- a/bot/seasons/evergreen/magic_8ball.py +++ b/bot/seasons/evergreen/magic_8ball.py @@ -13,7 +13,7 @@ class Magic8ball(commands.Cog): def __init__(self, bot): self.bot = bot - with open(Path("bot", "resources", "evergreen", "magic8ball.json"), "r") as file: + with open(Path("bot/resources/evergreen/magic8ball.json"), "r") as file: self.answers = json.load(file) @commands.command(name="8ball") diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py index 3754a122..88fb2032 100644 --- a/bot/seasons/evergreen/snakes/utils.py +++ b/bot/seasons/evergreen/snakes/utils.py @@ -13,7 +13,7 @@ from PIL.ImageDraw import ImageDraw from discord import File, Member, Reaction from discord.ext.commands import Context -SNAKE_RESOURCES = Path('bot', 'resources', 'snakes').absolute() +SNAKE_RESOURCES = Path("bot/resources/snakes").absolute() h1 = r'''``` ---- diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index d7bddbfb..faf59ca9 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -8,7 +8,7 @@ from discord.ext import commands log = logging.getLogger(__name__) -with open(Path('bot', 'resources', 'halloween', 'responses.json'), 'r', encoding="utf8") as f: +with open(Path("bot/resources/halloween/responses.json"), "r", encoding="utf8") as f: responses = json.load(f) diff --git a/bot/seasons/halloween/hacktoberstats.py b/bot/seasons/halloween/hacktoberstats.py index c30ad90f..b6b5a900 100644 --- a/bot/seasons/halloween/hacktoberstats.py +++ b/bot/seasons/halloween/hacktoberstats.py @@ -18,7 +18,7 @@ class HacktoberStats(commands.Cog): def __init__(self, bot): self.bot = bot - self.link_json = Path("bot", "resources", "github_links.json") + self.link_json = Path("bot/resources/github_links.json") self.linked_accounts = self.load_linked_users() @commands.group( diff --git a/bot/seasons/halloween/halloween_facts.py b/bot/seasons/halloween/halloween_facts.py index 00d91bc5..f09aa4ad 100644 --- a/bot/seasons/halloween/halloween_facts.py +++ b/bot/seasons/halloween/halloween_facts.py @@ -30,7 +30,7 @@ class HalloweenFacts(commands.Cog): def __init__(self, bot): self.bot = bot - with open(Path("bot", "resources", "halloween", "halloween_facts.json"), "r") as file: + with open(Path("bot/resources/halloween/halloween_facts.json"), "r") as file: self.halloween_facts = json.load(file) self.channel = None self.facts = list(enumerate(self.halloween_facts)) diff --git a/bot/seasons/halloween/halloweenify.py b/bot/seasons/halloween/halloweenify.py index 4d56e2f8..334781ab 100644 --- a/bot/seasons/halloween/halloweenify.py +++ b/bot/seasons/halloween/halloweenify.py @@ -21,23 +21,23 @@ class Halloweenify(commands.Cog): async def halloweenify(self, ctx): """Change your nickname into a much spookier one!""" async with ctx.typing(): - with open(Path('bot', 'resources', 'halloween', 'halloweenify.json'), 'r') as f: + with open(Path("bot/resources/halloween/halloweenify.json"), "r") as f: data = load(f) # Choose a random character from our list we loaded above and set apart the nickname and image url. - character = choice(data['characters']) + character = choice(data["characters"]) nickname = ''.join([nickname for nickname in character]) image = ''.join([character[nickname] for nickname in character]) # Build up a Embed embed = discord.Embed() embed.colour = discord.Colour.dark_orange() - embed.title = 'Not spooky enough?' + embed.title = "Not spooky enough?" embed.description = ( - f'**{ctx.author.display_name}** wasn\'t spooky enough for you? That\'s understandable, ' - f'{ctx.author.display_name} isn\'t scary at all! ' - 'Let me think of something better. Hmm... I got it!\n\n ' - f'Your new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:' + f"**{ctx.author.display_name}** wasn\'t spooky enough for you? That\'s understandable, " + f"{ctx.author.display_name} isn\'t scary at all! " + "Let me think of something better. Hmm... I got it!\n\n " + f"Your new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:" ) embed.set_image(url=image) diff --git a/bot/seasons/halloween/spookyrating.py b/bot/seasons/halloween/spookyrating.py index 18a963e0..08c17a27 100644 --- a/bot/seasons/halloween/spookyrating.py +++ b/bot/seasons/halloween/spookyrating.py @@ -11,7 +11,7 @@ from bot.constants import Colours log = logging.getLogger(__name__) -with Path('bot', 'resources', 'halloween', 'spooky_rating.json').open() as file: +with Path("bot/resources/halloween/spooky_rating.json").open() as file: SPOOKY_DATA = json.load(file) SPOOKY_DATA = sorted((int(key), value) for key, value in SPOOKY_DATA.items()) diff --git a/bot/seasons/halloween/spookysound.py b/bot/seasons/halloween/spookysound.py index 995f0403..44fdd9d6 100644 --- a/bot/seasons/halloween/spookysound.py +++ b/bot/seasons/halloween/spookysound.py @@ -15,7 +15,7 @@ class SpookySound(commands.Cog): def __init__(self, bot): self.bot = bot - self.sound_files = list(Path("bot", "resources", "halloween", "spookysounds").glob("*.mp3")) + self.sound_files = list(Path("bot/resources/halloween/spookysounds").glob("*.mp3")) self.channel = None @commands.cooldown(rate=1, per=1) diff --git a/bot/seasons/pride/pride_anthem.py b/bot/seasons/pride/pride_anthem.py new file mode 100644 index 00000000..f226f4bb --- /dev/null +++ b/bot/seasons/pride/pride_anthem.py @@ -0,0 +1,58 @@ +import json +import logging +import random +from pathlib import Path + +from discord.ext import commands + +log = logging.getLogger(__name__) + + +class PrideAnthem(commands.Cog): + """Embed a random youtube video for a gay anthem!""" + + def __init__(self, bot): + self.bot = bot + self.anthems = self.load_vids() + + def get_video(self, genre: str = None) -> dict: + """ + Picks a random anthem from the list. + + If `genre` is supplied, it will pick from videos attributed with that genre. + If none can be found, it will log this as well as provide that information to the user. + """ + if not genre: + return random.choice(self.anthems) + else: + songs = [song for song in self.anthems if genre.casefold() in song["genre"]] + try: + return random.choice(songs) + except IndexError: + log.info("No videos for that genre.") + + @staticmethod + def load_vids() -> list: + """Loads a list of videos from the resources folder as dictionaries.""" + with open(Path("bot/resources/pride/anthems.json"), "r", encoding="utf-8") as f: + anthems = json.load(f) + return anthems + + @commands.command(name="prideanthem", aliases=["anthem", "pridesong"]) + async def prideanthem(self, ctx, genre: str = None): + """ + Sends a message with a video of a random pride anthem. + + If `genre` is supplied, it will select from that genre only. + """ + anthem = self.get_video(genre) + if anthem: + await ctx.send(anthem["url"]) + else: + await ctx.send("I couldn't find a video, sorry!") + + +def setup(bot): + """Cog loader for pride anthem.""" + bot.add_cog(PrideAnthem(bot)) + log.info("Pride anthems cog loaded!") diff --git a/bot/seasons/pride/pride_avatar.py b/bot/seasons/pride/pride_avatar.py index b7cd1331..a5b38d20 100644 --- a/bot/seasons/pride/pride_avatar.py +++ b/bot/seasons/pride/pride_avatar.py @@ -106,7 +106,7 @@ class PrideAvatar(commands.Cog): avatar = self.crop_avatar(avatar) - ring = Image.open(Path("bot", "resources", "pride", "flags", f"{flag}.png")).resize((1024, 1024)) + ring = Image.open(Path(f"bot/resources/pride/flags/{flag}.png")).resize((1024, 1024)) ring = ring.convert("RGBA") ring = self.crop_ring(ring, pixels) diff --git a/bot/seasons/season.py b/bot/seasons/season.py index 95e3cf1d..71324127 100644 --- a/bot/seasons/season.py +++ b/bot/seasons/season.py @@ -24,7 +24,7 @@ def get_seasons() -> List[str]: """Returns all the Season objects located in /bot/seasons/.""" seasons = [] - for module in pkgutil.iter_modules([Path("bot", "seasons")]): + for module in pkgutil.iter_modules([Path("bot/seasons")]): if module.ispkg: seasons.append(module.name) return seasons @@ -331,7 +331,7 @@ class SeasonBase: for ext_folder in {self.name, "evergreen"}: if ext_folder: log.info(f"Start loading extensions from seasons/{ext_folder}/") - path = Path("bot", "seasons", ext_folder) + path = Path("bot/seasons") / ext_folder for ext_name in [i[1] for i in pkgutil.iter_modules([path])]: extensions.append(f"bot.seasons.{ext_folder}.{ext_name}") diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 08fea33d..ac140896 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -25,7 +25,7 @@ class BeMyValentine(commands.Cog): @staticmethod def load_json(): """Load Valentines messages from the static resources.""" - p = Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json') + p = Path("bot/resources/valentines/bemyvalentine_valentines.json") with p.open() as json_data: valentines = load(json_data) return valentines diff --git a/bot/seasons/valentines/lovecalculator.py b/bot/seasons/valentines/lovecalculator.py index ca8eaaf6..1d5a028d 100644 --- a/bot/seasons/valentines/lovecalculator.py +++ b/bot/seasons/valentines/lovecalculator.py @@ -15,7 +15,7 @@ from bot.constants import Roles log = logging.getLogger(__name__) -with Path('bot', 'resources', 'valentines', 'love_matches.json').open() as file: +with Path("bot/resources/valentines/love_matches.json").open() as file: LOVE_DATA = json.load(file) LOVE_DATA = sorted((int(key), value) for key, value in LOVE_DATA.items()) diff --git a/bot/seasons/valentines/myvalenstate.py b/bot/seasons/valentines/myvalenstate.py index 6a8d8b1d..fad202e3 100644 --- a/bot/seasons/valentines/myvalenstate.py +++ b/bot/seasons/valentines/myvalenstate.py @@ -11,7 +11,7 @@ from bot.constants import Colours log = logging.getLogger(__name__) -with open(Path('bot', 'resources', 'valentines', 'valenstates.json'), 'r') as file: +with open(Path("bot/resources/valentines/valenstates.json"), "r") as file: STATES = json.load(file) diff --git a/bot/seasons/valentines/pickuplines.py b/bot/seasons/valentines/pickuplines.py index 00ed5453..46772197 100644 --- a/bot/seasons/valentines/pickuplines.py +++ b/bot/seasons/valentines/pickuplines.py @@ -10,7 +10,7 @@ from bot.constants import Colours log = logging.getLogger(__name__) -with open(Path('bot', 'resources', 'valentines', 'pickup_lines.json'), 'r', encoding="utf8") as f: +with open(Path("bot/resources/valentines/pickup_lines.json"), "r", encoding="utf8") as f: pickup_lines = load(f) diff --git a/bot/seasons/valentines/savethedate.py b/bot/seasons/valentines/savethedate.py index a2d9a22d..34264183 100644 --- a/bot/seasons/valentines/savethedate.py +++ b/bot/seasons/valentines/savethedate.py @@ -12,7 +12,7 @@ log = logging.getLogger(__name__) HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -with open(Path('bot', 'resources', 'valentines', 'date_ideas.json'), 'r', encoding="utf8") as f: +with open(Path("bot/resources/valentines/date_ideas.json"), "r", encoding="utf8") as f: VALENTINES_DATES = load(f) diff --git a/bot/seasons/valentines/valentine_zodiac.py b/bot/seasons/valentines/valentine_zodiac.py index 7f78d3bc..fa849cb2 100644 --- a/bot/seasons/valentines/valentine_zodiac.py +++ b/bot/seasons/valentines/valentine_zodiac.py @@ -24,7 +24,7 @@ class ValentineZodiac(commands.Cog): @staticmethod def load_json(): """Load zodiac compatibility from static JSON resource.""" - p = Path('bot', 'resources', 'valentines', 'zodiac_compatibility.json') + p = Path("bot/resources/valentines/zodiac_compatibility.json") with p.open() as json_data: zodiacs = load(json_data) return zodiacs diff --git a/bot/seasons/valentines/whoisvalentine.py b/bot/seasons/valentines/whoisvalentine.py index 0a868fe6..d73ccd9b 100644 --- a/bot/seasons/valentines/whoisvalentine.py +++ b/bot/seasons/valentines/whoisvalentine.py @@ -10,7 +10,7 @@ from bot.constants import Colours log = logging.getLogger(__name__) -with open(Path("bot", "resources", "valentines", "valentine_facts.json"), "r") as file: +with open(Path("bot/resources/valentines/valentine_facts.json"), "r") as file: FACTS = json.load(file) |