diff options
| author | 2020-02-06 21:40:40 +0000 | |
|---|---|---|
| committer | 2020-02-06 21:40:40 +0000 | |
| commit | 9e758d49a905b5e0c7ee8e722c331157888b7ba9 (patch) | |
| tree | 64e95c43444cd9b65bd8f939d9da4dc7736089f8 /bot/seasons/evergreen/speedrun.py | |
| parent | Post results and boards to initial channel (diff) | |
| parent | Update CODEOWNERS (diff) | |
Merge branch 'master' into battleships
Diffstat (limited to 'bot/seasons/evergreen/speedrun.py')
| -rw-r--r-- | bot/seasons/evergreen/speedrun.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bot/seasons/evergreen/speedrun.py b/bot/seasons/evergreen/speedrun.py new file mode 100644 index 00000000..76c5e8d3 --- /dev/null +++ b/bot/seasons/evergreen/speedrun.py @@ -0,0 +1,28 @@ +import json +import logging +from pathlib import Path +from random import choice + +from discord.ext import commands + +log = logging.getLogger(__name__) +with Path('bot/resources/evergreen/speedrun_links.json').open(encoding="utf-8") as file: + LINKS = json.load(file) + + +class Speedrun(commands.Cog): + """Commands about the video game speedrunning community.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.command(name="speedrun") + async def get_speedrun(self, ctx: commands.Context) -> None: + """Sends a link to a video of a random speedrun.""" + await ctx.send(choice(LINKS)) + + +def setup(bot: commands.Bot) -> None: + """Load the Speedrun cog.""" + bot.add_cog(Speedrun(bot)) + log.info("Speedrun cog loaded") |