diff options
author | 2021-05-19 08:47:16 +0100 | |
---|---|---|
committer | 2021-05-19 08:47:16 +0100 | |
commit | c9114d0d7c14b7a9a985ffa000b154e3fd738e8c (patch) | |
tree | 6a9a08efd71277524bad52b0c2d70a585bcde8aa /bot/exts/evergreen/trivia_quiz.py | |
parent | Use an actual EST timezone (diff) | |
parent | Merge pull request #740 from python-discord/fix/wrong-source-message (diff) |
Merge branch 'main' into remove-superfluous-dependencies
Diffstat (limited to 'bot/exts/evergreen/trivia_quiz.py')
-rw-r--r-- | bot/exts/evergreen/trivia_quiz.py | 30 |
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") |