diff options
| author | 2019-08-09 15:56:29 -0400 | |
|---|---|---|
| committer | 2019-08-09 15:56:29 -0400 | |
| commit | c467362ea2c8a675ca67f7b612015bfef3dba2aa (patch) | |
| tree | 527395b451a1bd57bd9ab76366b4bf9539442357 | |
| parent | Merge pull request #249 from python-discord/snakes-and-ladders-bytesio-fix (diff) | |
added speedrun cog and its resource
Diffstat (limited to '')
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | bot/resources/evergreen/speedrun_links.json | 20 | ||||
| -rw-r--r-- | bot/seasons/evergreen/speedrun.py | 34 | 
3 files changed, 58 insertions, 1 deletions
@@ -111,4 +111,7 @@ venv.bak/  # jetbrains  .idea/ -.DS_Store
\ No newline at end of file +.DS_Store + +# vscode  +.vscode/ diff --git a/bot/resources/evergreen/speedrun_links.json b/bot/resources/evergreen/speedrun_links.json new file mode 100644 index 00000000..1ae1e325 --- /dev/null +++ b/bot/resources/evergreen/speedrun_links.json @@ -0,0 +1,20 @@ +{ +    "links": [ +        "https://www.youtube.com/watch?v=jNE28SDXdyQ", +        "https://www.youtube.com/watch?v=iI8Giq7zQDk", +        "https://www.youtube.com/watch?v=VqNnkqQgFbc", +        "https://www.youtube.com/watch?v=Gum4GI2Jr0s", +        "https://www.youtube.com/watch?v=5YHjHzHJKkU", +        "https://www.youtube.com/watch?v=X0pJSTy4tJI", +        "https://www.youtube.com/watch?v=aVFq0H6D6_M", +        "https://www.youtube.com/watch?v=1O6LuJbEbSI", +        "https://www.youtube.com/watch?v=Bgh30BiWG58", +        "https://www.youtube.com/watch?v=wwvgAAvhxM8", +        "https://www.youtube.com/watch?v=0TWQr0_fi80", +        "https://www.youtube.com/watch?v=hatqZby-0to", +        "https://www.youtube.com/watch?v=X0pJSTy4tJI", +        "https://www.youtube.com/watch?v=tmnMq2Hw72w", +        "https://www.youtube.com/watch?v=UTkyeTCAucA", +        "https://www.youtube.com/watch?v=67kQ3l-1qMs" +    ] +}
\ No newline at end of file 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")  |