diff options
| author | 2019-08-09 15:56:29 -0400 | |
|---|---|---|
| committer | 2019-08-09 15:56:29 -0400 | |
| commit | c467362ea2c8a675ca67f7b612015bfef3dba2aa (patch) | |
| tree | 527395b451a1bd57bd9ab76366b4bf9539442357 /bot/seasons/evergreen | |
| parent | Merge pull request #249 from python-discord/snakes-and-ladders-bytesio-fix (diff) | |
added speedrun cog and its resource
Diffstat (limited to 'bot/seasons/evergreen')
| -rw-r--r-- | bot/seasons/evergreen/speedrun.py | 34 | 
1 files changed, 34 insertions, 0 deletions
diff --git a/bot/seasons/evergreen/speedrun.py b/bot/seasons/evergreen/speedrun.py new file mode 100644 index 00000000..8bbbfc83 --- /dev/null +++ b/bot/seasons/evergreen/speedrun.py @@ -0,0 +1,34 @@ +import json +import logging +from random import choice +from discord.ext import commands +from pathlib import Path + + +log = logging.getLogger(__name__) + + +class Speedrun(commands.Cog): +    """ +    A command that will link a random speedrun video from youtube to Discord. +    """ + +    def __init__(self, bot): +        self.bot = bot + +    @commands.command(name="speedrun") +    async def get_speedrun(self, ctx): +        """ +        Sends a link to Discord of a random speedrun from youtube. +        Utilizes speedrun_links.json to find links. +        """ + +        with open(Path('bot/resources/evergreen/speedrun_links.json')) as file: +            data = json.load(file) +        links = data['links'] +        await ctx.send(choice(links)) + + +def setup(bot): +    bot.add_cog(Speedrun(bot)) +    log.info("Speedrun cog loaded")  |