diff options
| author | 2019-04-23 12:54:42 -0400 | |
|---|---|---|
| committer | 2019-04-23 12:54:42 -0400 | |
| commit | 742e5b9d0f077f8b9ee97e3df4800a4a0ed4adad (patch) | |
| tree | 280ebbdf8d4eb44e65d3ed83ed3f5bfc0e4884f6 /bot/seasons | |
| parent | Merge pull request #196 from python-discord/hunt-fix (diff) | |
| parent | removed unused imports (diff) | |
Merge pull request #166 from RohanJnr/april_fools_vids
April fools vids
Diffstat (limited to 'bot/seasons')
| -rw-r--r-- | bot/seasons/easter/april_fools_vids.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bot/seasons/easter/april_fools_vids.py b/bot/seasons/easter/april_fools_vids.py new file mode 100644 index 00000000..5dae8485 --- /dev/null +++ b/bot/seasons/easter/april_fools_vids.py @@ -0,0 +1,38 @@ +import logging +import random +from json import load +from pathlib import Path + +from discord.ext import commands + +log = logging.getLogger(__name__) + + +class AprilFoolVideos(commands.Cog): + """A cog for april fools that gets a random april fools video from youtube.""" + def __init__(self, bot): + self.bot = bot + self.yt_vids = self.load_json() + self.youtubers = ['google'] # will add more in future + + @staticmethod + def load_json(): + """A function to load json data.""" + p = Path('bot', 'resources', 'easter', 'april_fools_vids.json') + with p.open() as json_file: + all_vids = load(json_file) + return all_vids + + @commands.command(name='fool') + async def aprial_fools(self, ctx): + """Gets a random april fools video from youtube.""" + random_youtuber = random.choice(self.youtubers) + category = self.yt_vids[random_youtuber] + random_vid = random.choice(category) + await ctx.send(f"Check out this April Fools' video by {random_youtuber}.\n\n{random_vid['link']}") + + +def setup(bot): + """A function to add the cog.""" + bot.add_cog(AprilFoolVideos(bot)) + log.info('April Fools videos cog loaded!') |