diff options
Diffstat (limited to 'bot/seasons/easter/easter_riddle.py')
| -rw-r--r-- | bot/seasons/easter/easter_riddle.py | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/bot/seasons/easter/easter_riddle.py b/bot/seasons/easter/easter_riddle.py index 3c24075c..56555586 100644 --- a/bot/seasons/easter/easter_riddle.py +++ b/bot/seasons/easter/easter_riddle.py @@ -33,62 +33,66 @@ class EasterRiddle(commands.Cog): The duration of the hint interval can be configured by changing the TIMELIMIT constant in this file. """ - if not self.current_channel: - self.current_channel = ctx.message.channel + if self.current_channel: + return await ctx.send(f"A riddle is already being solved in {self.current_channel.mention}!") - random_question = random.choice(RIDDLE_QUESTIONS) - question = random_question["question"] - hints = random_question["riddles"] - self.correct = random_question["correct_answer"] + self.current_channel = ctx.message.channel - description = f"You have {TIMELIMIT} seconds before the first hint.\n\n" + random_question = random.choice(RIDDLE_QUESTIONS) + question = random_question["question"] + hints = random_question["riddles"] + self.correct = random_question["correct_answer"] - riddle_embed = discord.Embed(title=question, description=description, colour=Colours.pink) + description = f"You have {TIMELIMIT} seconds before the first hint." - await ctx.send(embed=riddle_embed) - await asyncio.sleep(TIMELIMIT) + riddle_embed = discord.Embed(title=question, description=description, colour=Colours.pink) - hint_embed = discord.Embed( - title=f"Here's a hint: {hints[0]}!", - colour=Colours.pink - ) + await ctx.send(embed=riddle_embed) + await asyncio.sleep(TIMELIMIT) - await ctx.send(embed=hint_embed) - await asyncio.sleep(TIMELIMIT) + hint_embed = discord.Embed( + title=f"Here's a hint: {hints[0]}!", + colour=Colours.pink + ) - hint_embed = discord.Embed( - title=f"Here's a hint: {hints[1]}!", - colour=Colours.pink - ) + await ctx.send(embed=hint_embed) + await asyncio.sleep(TIMELIMIT) - await ctx.send(embed=hint_embed) - await asyncio.sleep(TIMELIMIT) + hint_embed = discord.Embed( + title=f"Here's a hint: {hints[1]}!", + colour=Colours.pink + ) - if self.winners: - win_list = " ".join(self.winners) - content = f"Well done {win_list} for getting it right!" - self.winners = [] - else: - content = "Nobody got it right..." + await ctx.send(embed=hint_embed) + await asyncio.sleep(TIMELIMIT) - answer_embed = discord.Embed( - title=f"The answer is: {self.correct}!", - colour=Colours.pink - ) + if self.winners: + win_list = " ".join(self.winners) + content = f"Well done {win_list} for getting it right!" + else: + content = "Nobody got it right..." - await ctx.send(content, embed=answer_embed) + answer_embed = discord.Embed( + title=f"The answer is: {self.correct}!", + colour=Colours.pink + ) - self.current_channel = None - else: - await ctx.send(f"A riddle is already being solved in {self.current_channel.mention}!") + await ctx.send(content, embed=answer_embed) + + self.winners = [] + self.current_channel = None @commands.Cog.listener() async def on_message(self, message): """If a non-bot user enters a correct answer, their username gets added to self.winners""" - if self.current_channel == message.channel: - if self.bot.user != message.author: - if message.content.lower() == self.correct.lower(): - self.winners.append(message.author.mention) + if self.current_channel != message.channel: + return + + if self.bot.user == message.author: + return + + if message.content.lower() == self.correct.lower(): + self.winners.append(message.author.mention) def setup(bot): |