diff options
| author | 2019-10-17 18:03:25 +0530 | |
|---|---|---|
| committer | 2019-10-17 18:03:25 +0530 | |
| commit | 1332d9e5eaf9e2d7fafa8f6c90216c2b012f3743 (patch) | |
| tree | f11662e6bee63a44549f1abe62f7ac5743e44ed2 | |
| parent | Updated the code as per the suggestions and they are the following: (diff) | |
fixed bugs such as incorrect time to send the category embed, game will no longer run again if stopped n stuff.
| -rw-r--r-- | bot/seasons/evergreen/trivia_quiz.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/bot/seasons/evergreen/trivia_quiz.py b/bot/seasons/evergreen/trivia_quiz.py index f7ad9f3a..d4e582af 100644 --- a/bot/seasons/evergreen/trivia_quiz.py +++ b/bot/seasons/evergreen/trivia_quiz.py @@ -58,29 +58,14 @@ class TriviaQuiz(commands.Cog): - general : Test your general knowledge. (default) (More to come!) """ - category = category.lower() - if ctx.channel.id not in self.game_status: self.game_status[ctx.channel.id] = False if ctx.channel.id not in self.game_player_scores: self.game_player_scores[ctx.channel.id] = {} - # Start game if not running. - if not self.game_status[ctx.channel.id]: - self.game_owners[ctx.channel.id] = ctx.author - self.game_status[ctx.channel.id] = True - start_embed = discord.Embed(colour=discord.Colour.red()) - start_embed.title = "Quiz game Starting!!" - start_embed.description = "Each game consists of 5 questions.\n" - start_embed.description += "**Rules :**\nNo cheating and have fun!" - start_embed.set_footer( - text="Points for a question reduces by 25 after 10s or after a hint. Total time is 30s per question" - ) - await ctx.send(embed=start_embed) # send an embed with the rules - await asyncio.sleep(1) # Stop game if running. - else: + if self.game_status[ctx.channel.id] is True: # Check if the author is the game starter or a moderator. if ( ctx.author == self.game_owners[ctx.channel.id] @@ -93,12 +78,29 @@ class TriviaQuiz(commands.Cog): self.game_player_scores[ctx.channel.id] = {} else: await ctx.send(f"{ctx.author.mention}, you are not authorised to stop this game :ghost: !") + return + category = category.lower() + # Send embed showing available categories if inputted category is invalid. if category not in self.categories: embed = self.category_embed await ctx.send(embed=embed) return + # Start game if not running. + if self.game_status[ctx.channel.id] is False: + self.game_owners[ctx.channel.id] = ctx.author + self.game_status[ctx.channel.id] = True + start_embed = discord.Embed(colour=discord.Colour.red()) + start_embed.title = "Quiz game Starting!!" + start_embed.description = "Each game consists of 5 questions.\n" + start_embed.description += "**Rules :**\nNo cheating and have fun!" + start_embed.set_footer( + text="Points for a question reduces by 25 after 10s or after a hint. Total time is 30s per question" + ) + await ctx.send(embed=start_embed) # send an embed with the rules + await asyncio.sleep(1) + topic = self.questions[category] done_question = [] |