aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/minesweeper.py
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-09-24 18:54:10 +0300
committerGravatar GitHub <[email protected]>2020-09-24 18:54:10 +0300
commit69d2292ec4b3fb2dc83f291ef1ed7bc86eabfd09 (patch)
treeb0c3c0991eef3fc278a0977baf129a7205ff469c /bot/exts/evergreen/minesweeper.py
parentMerge remote-tracking branch 'origin/tic-tac-toe' into tic-tac-toe (diff)
parentMerge pull request #456 from Anubhav1603/update_dpy (diff)
Merge branch 'master' into tic-tac-toe
Diffstat (limited to 'bot/exts/evergreen/minesweeper.py')
-rw-r--r--bot/exts/evergreen/minesweeper.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py
index ae057b30..3e40f493 100644
--- a/bot/exts/evergreen/minesweeper.py
+++ b/bot/exts/evergreen/minesweeper.py
@@ -141,9 +141,20 @@ class Minesweeper(commands.Cog):
await ctx.message.delete(delay=2)
return
+ try:
+ await ctx.author.send(
+ f"Play by typing: `{Client.prefix}ms reveal xy [xy]` or `{Client.prefix}ms flag xy [xy]` \n"
+ f"Close the game with `{Client.prefix}ms end`\n"
+ )
+ except discord.errors.Forbidden:
+ log.debug(f"{ctx.author.name} ({ctx.author.id}) has disabled DMs from server members")
+ await ctx.send(f":x: {ctx.author.mention}, please enable DMs to play minesweeper.")
+ return
+
# Add game to list
board: GameBoard = self.generate_board(bomb_chance)
revealed_board: GameBoard = [["hidden"] * 10 for _ in range(10)]
+ dm_msg = await ctx.author.send(f"Here's your board!\n{self.format_for_discord(revealed_board)}")
if ctx.guild:
await ctx.send(f"{ctx.author.mention} is playing Minesweeper")
@@ -151,12 +162,6 @@ class Minesweeper(commands.Cog):
else:
chat_msg = None
- await ctx.author.send(
- f"Play by typing: `{Client.prefix}ms reveal xy [xy]` or `{Client.prefix}ms flag xy [xy]` \n"
- f"Close the game with `{Client.prefix}ms end`\n"
- )
- dm_msg = await ctx.author.send(f"Here's your board!\n{self.format_for_discord(revealed_board)}")
-
self.games[ctx.author.id] = Game(
board=board,
revealed=revealed_board,