aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/evergreen/speedrun.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot/seasons/evergreen/speedrun.py')
-rw-r--r--bot/seasons/evergreen/speedrun.py34
1 files changed, 34 insertions, 0 deletions
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")