aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-04-08 20:01:17 +0300
committerGravatar ks129 <[email protected]>2020-04-08 20:01:17 +0300
commitb08c34b2009c0440da843b1405c98b104acbf173 (patch)
tree1817e7f81481c913a53f68c01d3a03ddebb7de86
parent(Minesweeper): Added raising `UserNotPlayingError`, attached flag command to ... (diff)
(Minesweeper): Moved `UserNotPlayingError` to `bot.utils.exceptions`, removed definition in extensions. Removed custom error handler.
-rw-r--r--bot/exts/evergreen/minesweeper.py15
-rw-r--r--bot/utils/exceptions.py6
2 files changed, 7 insertions, 14 deletions
diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py
index e98e9027..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:",
@@ -29,12 +30,6 @@ MESSAGE_MAPPING = {
log = logging.getLogger(__name__)
-class UserNotPlayingError(Exception):
- """Will raised when user try to use game commands when not playing."""
-
- pass
-
-
class CoordinateConverter(commands.Converter):
"""Converter for Coordinates."""
@@ -290,14 +285,6 @@ class Minesweeper(commands.Cog):
await game.chat_msg.edit(content=new_msg)
del self.games[ctx.author.id]
- @reveal_command.error
- @end_command.error
- @flag_command.error
- async def user_not_playing_handler(self, ctx: commands.Context, error: Exception) -> None:
- """Handle `KeyError` that is raised in reveal or end command when getting game."""
- if isinstance(error, UserNotPlayingError):
- await ctx.send("Game don't exist.")
-
def setup(bot: commands.Bot) -> None:
"""Load the Minesweeper cog."""
diff --git a/bot/utils/exceptions.py b/bot/utils/exceptions.py
index 70c20e12..dc62debe 100644
--- a/bot/utils/exceptions.py
+++ b/bot/utils/exceptions.py
@@ -2,3 +2,9 @@ class BrandingError(Exception):
"""Exception raised by the BrandingManager cog."""
pass
+
+
+class UserNotPlayingError(Exception):
+ """Will raised when user try to use game commands when not playing."""
+
+ pass