diff options
| author | 2020-04-08 18:15:24 +0100 | |
|---|---|---|
| committer | 2020-04-08 18:15:24 +0100 | |
| commit | 30b73caa8244d43a1d48a9a4e652543844bbad4d (patch) | |
| tree | 6b3a80dfcd00fcdf442495a161cad9032d5bbcd0 /bot/exts/evergreen/minesweeper.py | |
| parent | Merge pull request #392 from python-discord/fetch-devlog-channel (diff) | |
| parent | (Error Handler): Added `UserNotPlayingError` catching to error handler. (diff) | |
Merge pull request #396 from ks129/keyerrors-fix
* Add error handling for invalid APOD dates
* Add error handling for non-existent minesweeper games
Diffstat (limited to 'bot/exts/evergreen/minesweeper.py')
| -rw-r--r-- | bot/exts/evergreen/minesweeper.py | 7 | 
1 files changed, 7 insertions, 0 deletions
| diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py index b59cdb14..ae057b30 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/evergreen/minesweeper.py @@ -7,6 +7,7 @@ import discord  from discord.ext import commands  from bot.constants import Client +from bot.utils.exceptions import UserNotPlayingError  MESSAGE_MAPPING = {      0: ":stop_button:", @@ -176,6 +177,8 @@ class Minesweeper(commands.Cog):      @minesweeper_group.command(name="flag")      async def flag_command(self, ctx: commands.Context, *coordinates: CoordinateConverter) -> None:          """Place multiple flags on the board.""" +        if ctx.author.id not in self.games: +            raise UserNotPlayingError          board: GameBoard = self.games[ctx.author.id].revealed          for x, y in coordinates:              if board[y][x] == "hidden": @@ -253,6 +256,8 @@ class Minesweeper(commands.Cog):      @minesweeper_group.command(name="reveal")      async def reveal_command(self, ctx: commands.Context, *coordinates: CoordinateConverter) -> None:          """Reveal multiple cells.""" +        if ctx.author.id not in self.games: +            raise UserNotPlayingError          game = self.games[ctx.author.id]          revealed: GameBoard = game.revealed          board: GameBoard = game.board @@ -269,6 +274,8 @@ class Minesweeper(commands.Cog):      @minesweeper_group.command(name="end")      async def end_command(self, ctx: commands.Context) -> None:          """End your current game.""" +        if ctx.author.id not in self.games: +            raise UserNotPlayingError          game = self.games[ctx.author.id]          game.revealed = game.board          await self.update_boards(ctx) | 
