blob: 8bbbfc8320b9cbb621928f18864c59221417659a (
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
29
30
31
32
33
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")
|