aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/evergreen/speedrun.py
blob: 3cf531bf397401685f9b02bd5aae8166656b0420 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import logging
from pathlib import Path
from random import choice

from discord.ext import commands

log = logging.getLogger(__name__)


class Speedrun(commands.Cog):
    """Commands about the video game speedrunning community."""

    def __init__(self, bot):
        self.bot = bot
        with Path('bot/resources/evergreen/speedrun_links.json').open(encoding="utf-8") as file:
            self.data = json.load(file)

    @commands.command(name="speedrun")
    async def get_speedrun(self, ctx):
        """Sends a link to a video of a random speedrun."""
        await ctx.send(choice(self.data))


def setup(bot):
    """Load the Speedrun cog"""
    bot.add_cog(Speedrun(bot))
    log.info("Speedrun cog loaded")