aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons
diff options
context:
space:
mode:
authorGravatar RohanRadia <[email protected]>2019-04-09 13:26:58 +0100
committerGravatar RohanRadia <[email protected]>2019-04-09 13:26:58 +0100
commit262f3a8df49fc7bbf8b76956e981a00a38bd65d6 (patch)
tree7811922b6f295d431a9793aace96c78a15e49df3 /bot/seasons
parentMerge pull request #1 from python-discord/master (diff)
Created the spooky8ball command and the corresponding .json responses file.
Diffstat (limited to 'bot/seasons')
-rw-r--r--bot/seasons/halloween/8ball.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py
new file mode 100644
index 00000000..6f89375e
--- /dev/null
+++ b/bot/seasons/halloween/8ball.py
@@ -0,0 +1,39 @@
+import asyncio
+import json
+import logging
+import random
+from pathlib import Path
+
+from discord.ext import commands
+
+log = logging.getLogger(__name__)
+
+with open(Path('bot', 'resources', 'halloween', 'responses.json'), 'r', encoding="utf8") as f:
+ responses = json.load(f)
+
+
+class EightBall(commands.Cog):
+ """Spooky Eightball answers."""
+
+ def __init__(self, bot):
+ self.bot = bot
+
+ @commands.command(aliases=('spooky8ball'))
+ async def spookyeightball(self, ctx, question: str):
+ """Responds with a random response to a question."""
+
+ choice = random.choice(responses)
+ if len(choice) == 1:
+ await ctx.send(choice[0])
+ else:
+ for x in choice:
+ await ctx.send(x)
+ asyncio.sleep(random.randint(2, 5))
+ await ctx.send(x)
+
+
+def setup(bot):
+ """Conversation starters Cog load."""
+
+ bot.add_cog(EightBall(bot))
+ log.info("8Ball cog loaded")