async def scrambivia_loop(self): if self.game: loop = asyncio.get_running_loop() self.round += 1 if (self.round > self.maxRound): await self.stop() return self.question, self.answer = triviautil.fetch_question() self.accepting_answers = True res = discord.Embed( title="Scrambivia Round " + str(self.round) + " of " + str(self.maxRound), description=util.insert_zero_width_space(self.question) + "\nAnswer: \"" + util.bold(unscrambleutil.scramble(self.answer)) + "\"", color=util.generate_random_color()) await self.ctx.send(embed=res) self.timer = loop.time() + self.roundTimer while self.game: if (loop.time()) >= self.timer: self.accepting_answers = False res = discord.Embed(title="Round over!", description="The answer was: " + util.bold(str(self.answer)), color=util.generate_random_color()) await self.ctx.send(embed=res) await asyncio.sleep(2) await self.scrambivia_loop() break await asyncio.sleep(1)
async def handle_on_message(self, message): if triviautil.valid_guess(message.content.lower(), self.answer, self.similarity) and self.accepting_answers: self.accepting_answers = False if message.author.name not in self.trackedPlayers: self.trackedPlayers[message.author.name] = 1 else: self.trackedPlayers[message.author.name] += 1 await message.add_reaction('✅') self.timer = 0 if message.content == "!scramble" and self.scramble and self.accepting_answers: res = discord.Embed(title=unscrambleutil.scramble(self.answer)) await message.channel.send(embed=res)
async def handle_on_message(self, message): if self.accepting_answers: if triviautil.valid_guess(message.content, self.answer): self.accepting_answers = False if message.author.name not in self.trackedPlayers: self.trackedPlayers[message.author.name] = 1 else: self.trackedPlayers[message.author.name] += 1 await message.add_reaction('✅') self.timer = 0 if message.content == '!scramble': res = discord.Embed(title=unscrambleutil.scramble(self.answer), color=util.generate_random_color()) await self.ctx.send(embed=res)
async def trivia_loop(self): if self.game: loop = asyncio.get_running_loop() self.round += 1 if (self.round > self.maxRound): await self.stop() return self.question, self.answer = powutil.insert_zero_width_space( self.questionList[self.round - 1] ["question"]), self.questionList[self.round - 1]["answer"].lower().replace( "<i>", "").replace("</i>", "") if self.answer.startswith("the "): self.answer = self.answer[4:] if self.answer.startswith("an "): self.answer = self.answer[3:] if self.answer.startswith("a "): self.answer = self.answer[2:] self.accepting_answers = True desc = util.insert_zero_width_space(self.question) if self.scramble: desc += "\nUnscramble: \"" + util.bold( unscrambleutil.scramble(self.answer)) + "\"" res = discord.Embed(title="jsTrivia Round " + str(self.round) + " of " + str(self.maxRound), description=desc, color=util.generate_random_color()) await self.ctx.send(embed=res) self.timer = loop.time() + self.roundTimer while self.game: if (loop.time()) >= self.timer: self.accepting_answers = False res = discord.Embed(title="Round over!", description="The answer was: " + util.bold(str(self.answer)), color=util.generate_random_color()) await self.ctx.send(embed=res) await asyncio.sleep(2) await self.trivia_loop() break await asyncio.sleep(1)
async def scramble(self): if self.currentWord != "" and self.game: res = discord.Embed(title=unscrambleutil.scramble(self.currentWord), color=util.generate_random_color()) await self.ctx.send(embed=res)