diff options
author | 2019-05-13 20:56:58 +1000 | |
---|---|---|
committer | 2019-05-13 20:56:58 +1000 | |
commit | eea7de2f08ce554f22c568719f5f12616096001b (patch) | |
tree | 4ec2cf46f9674c231264fd462057cce45035bca9 | |
parent | Merge pull request #201 from python-discord/pypi-dpy (diff) | |
parent | Removed unused import. (diff) |
Spooky 8 Ball (#189)
Spooky 8 Ball
Co-authored-by: Josué D. (JD) <[email protected]>
-rw-r--r-- | bot/resources/halloween/responses.json | 14 | ||||
-rw-r--r-- | bot/seasons/halloween/8ball.py | 35 |
2 files changed, 49 insertions, 0 deletions
diff --git a/bot/resources/halloween/responses.json b/bot/resources/halloween/responses.json new file mode 100644 index 00000000..c0f24c1a --- /dev/null +++ b/bot/resources/halloween/responses.json @@ -0,0 +1,14 @@ +{ + "responses": [ + ["No."], + ["Yes."], + ["I will seek and answer from the devil...", "...after requesting the devils knowledge the answer is far more complicated than a simple yes or no."], + ["This knowledge is not available to me, I will seek the answers from someone far more powerful...", "...there is no answer to this question, not even the Grim Reaper could find an answer."], + ["The ghosts I summoned have confirmed that is is certain."], + ["Double, double, toil and trouble,\nFire burn and cauldron bubble.\nCool it with a baboon's blood,\nand tell me the answer to his question...", "...the great cauldron can only confirm your beliefs."], + ["Double, double, toil and trouble,\nFire burn and cauldron bubble.\nCool it with a baboon's blood,\nand tell me the answer to his question...", "...the great cauldron can only confirm that the answer to your question is no."], + ["If I tell you I will have to kill you..."], + ["I swear on my spider that you are correct."], + ["With great certainty, under the watch of the Pumpkin King, I can confirm your suspicions."], + ["The undead have sworn me to secrecy. I can not answer your question."] +]} diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py new file mode 100644 index 00000000..af037e53 --- /dev/null +++ b/bot/seasons/halloween/8ball.py @@ -0,0 +1,35 @@ +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 SpookyEightBall(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['responses']) + msg = await ctx.send(choice[0]) + if len(choice) > 1: + await asyncio.sleep(random.randint(2, 5)) + await msg.edit(content=f"{choice[0]} \n{choice[1]}") + + +def setup(bot): + """Spooky Eight Ball Cog Load.""" + + bot.add_cog(SpookyEightBall(bot)) + log.info("SpookyEightBall cog loaded") |