aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar RohanRadia <[email protected]>2019-05-11 12:23:33 +0100
committerGravatar GitHub <[email protected]>2019-05-11 12:23:33 +0100
commit225ff72c0c37035122b017c9af2dd71dd4d7f115 (patch)
tree786de53fa89e00474489b7ae3bb5aa6d705d9a2f /bot
parentUpdated the docstring (diff)
Added embed to stop double message confusion and fixed sleep to asyncio.sleep()
Diffstat (limited to 'bot')
-rw-r--r--bot/seasons/halloween/8ball.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py
index 750b489f..de30fa78 100644
--- a/bot/seasons/halloween/8ball.py
+++ b/bot/seasons/halloween/8ball.py
@@ -1,4 +1,5 @@
import asyncio
+import discord
import json
import logging
import random
@@ -13,27 +14,29 @@ with open(Path('bot', 'resources', 'halloween', 'responses.json'), 'r', encoding
class EightBall(commands.Cog):
- """Spooky Eightball - upon use of the command the user receives a randomised response to their question!"""
+ """Spooky Eightball answers."""
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=('spooky8ball',))
- async def spookyeightball(self, ctx, question: str):
+ async def spookyeightball(self, ctx, *, question: str):
"""Responds with a random response to a question."""
-
- choice = random.choice(responses)
+ choice = random.choice(responses['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)
+ emb = discord.Embed(colour=0x00f2ff)
+ emb.add_field(name=f'Question from {ctx.author.name}', value=question)
+ emb.add_field(name='Answer', value=choice[0])
+ msg = await ctx.send(embed=emb)
+ await asyncio.sleep(random.randint(2, 5))
+ emb.set_field_at(1, name='Answer', value=f'{choice[0]} \n {choice[1]}')
+ await msg.edit(embed=emb)
def setup(bot):
- """Conversation starters Cog load."""
+ """Spooky Eight Ball Cog Load."""
bot.add_cog(EightBall(bot))
log.info("8Ball cog loaded")