diff options
author | 2021-04-12 19:54:19 +0100 | |
---|---|---|
committer | 2021-04-12 19:54:19 +0100 | |
commit | 607e83bf78728f990377cf3f8d0c3b080b07476b (patch) | |
tree | c7efe7a34428a0221fe6c0b3d99e91f50ebae300 /bot | |
parent | feat: rewrite portion of fool command to allow all videos (diff) |
chore: remove unnecessary utility function and simplify code
Diffstat (limited to 'bot')
-rw-r--r-- | bot/exts/easter/april_fools_vids.py | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/bot/exts/easter/april_fools_vids.py b/bot/exts/easter/april_fools_vids.py index 97cb407c..c7a3c014 100644 --- a/bot/exts/easter/april_fools_vids.py +++ b/bot/exts/easter/april_fools_vids.py @@ -1,32 +1,22 @@ import logging import random from json import load -from pathlib import Path from discord.ext import commands log = logging.getLogger(__name__) +with open("bot/resources/easter/april_fools_vids.json", encoding="utf-8") as f: + ALL_VIDS = load(f) + class AprilFoolVideos(commands.Cog): """A cog for April Fools' that gets a random April Fools' video from Youtube.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - self.yt_vids = self.load_json() - - @staticmethod - def load_json() -> dict: - """A function to load JSON data.""" - p = Path('bot/resources/easter/april_fools_vids.json') - with p.open(encoding="utf-8") as json_file: - all_vids = load(json_file) - return all_vids - @commands.command(name='fool') async def april_fools(self, ctx: commands.Context) -> None: """Get a random April Fools' video from Youtube.""" - video = random.choice(self.yt_vids) + video = random.choice(ALL_VIDS) channel, url = video["channel"], video["url"] |