diff options
| author | 2020-03-28 15:13:26 +0100 | |
|---|---|---|
| committer | 2020-03-28 15:13:26 +0100 | |
| commit | 294915013680c9ad205d6c9fa0c7fa2b79cc1919 (patch) | |
| tree | 117612b7f890e35010fe53575879edc1c41362e0 /bot/exts/evergreen/speedrun.py | |
| parent | Deseasonify: info log on help cog load (diff) | |
Deseasonify: rename `seasons` pkg to `exts`
It is believed that this is now a more logical name for the package,
as extensions no longer bind to seasons.
Internally, packages are still grouped into seasonal sub-packages.
There are quite a few, and it makes sense to group them by a common
theme that inspired their functionality.
Diffstat (limited to 'bot/exts/evergreen/speedrun.py')
| -rw-r--r-- | bot/exts/evergreen/speedrun.py | 28 | 
1 files changed, 28 insertions, 0 deletions
| diff --git a/bot/exts/evergreen/speedrun.py b/bot/exts/evergreen/speedrun.py new file mode 100644 index 00000000..76c5e8d3 --- /dev/null +++ b/bot/exts/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") | 
