aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/evergreen/speedrun.py
diff options
context:
space:
mode:
authorGravatar S. Co1 <[email protected]>2019-08-13 19:31:04 -0400
committerGravatar GitHub <[email protected]>2019-08-13 19:31:04 -0400
commitfceb30cd8e9f346842eaed7b0d45001172ef1500 (patch)
tree562b5d75f2098c09a41eb66f0d0b44db8341a645 /bot/seasons/evergreen/speedrun.py
parentMerge pull request #249 from python-discord/snakes-and-ladders-bytesio-fix (diff)
parentmoved data grab to module level, changed var to constant (diff)
Merge pull request #254 from jakeHebert/master
Add speedrun cog and resource
Diffstat (limited to 'bot/seasons/evergreen/speedrun.py')
-rw-r--r--bot/seasons/evergreen/speedrun.py28
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..f6a43a63
--- /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):
+ self.bot = bot
+
+ @commands.command(name="speedrun")
+ async def get_speedrun(self, ctx):
+ """Sends a link to a video of a random speedrun."""
+ await ctx.send(choice(LINKS))
+
+
+def setup(bot):
+ """Load the Speedrun cog"""
+ bot.add_cog(Speedrun(bot))
+ log.info("Speedrun cog loaded")