aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-05-18 17:52:53 +0100
committerGravatar GitHub <[email protected]>2021-05-18 17:52:53 +0100
commit61801cd9f9570db8d1cf5a72bdba51070612b1d4 (patch)
tree16501143b998a18d3269e43ceba33553c49e9f15
parentMerge branch 'main' into fix/wrong-source-message (diff)
parentMerge pull request #741 from python-discord/fix/quiz-keyerror (diff)
Merge branch 'main' into fix/wrong-source-message
-rw-r--r--bot/exts/evergreen/trivia_quiz.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/bot/exts/evergreen/trivia_quiz.py b/bot/exts/evergreen/trivia_quiz.py
index 419126dc..a8d10afd 100644
--- a/bot/exts/evergreen/trivia_quiz.py
+++ b/bot/exts/evergreen/trivia_quiz.py
@@ -465,22 +465,24 @@ class TriviaQuiz(commands.Cog):
Note: Only mods or the owner of the quiz can stop it.
"""
- 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] or any(
- Roles.moderator == role.id for role in ctx.author.roles
- ):
-
- await ctx.send("Quiz stopped.")
- await self.declare_winner(ctx.channel, self.game_player_scores[ctx.channel.id])
-
- self.game_status[ctx.channel.id] = False
- del self.game_owners[ctx.channel.id]
- self.game_player_scores[ctx.channel.id] = {}
+ try:
+ if self.game_status[ctx.channel.id]:
+ # Check if the author is the game starter or a moderator.
+ if ctx.author == self.game_owners[ctx.channel.id] or any(
+ Roles.moderator == role.id for role in ctx.author.roles
+ ):
+ self.game_status[ctx.channel.id] = False
+ del self.game_owners[ctx.channel.id]
+ self.game_player_scores[ctx.channel.id] = {}
+
+ await ctx.send("Quiz stopped.")
+ await self.declare_winner(ctx.channel, self.game_player_scores[ctx.channel.id])
+ else:
+ await ctx.send(f"{ctx.author.mention}, you are not authorised to stop this game :ghost:!")
else:
- await ctx.send(f"{ctx.author.mention}, you are not authorised to stop this game :ghost:!")
- else:
+ await ctx.send("No quiz running.")
+ except KeyError:
await ctx.send("No quiz running.")
@quiz_game.command(name="leaderboard")