diff options
author | 2020-04-26 05:51:51 +0300 | |
---|---|---|
committer | 2020-04-26 05:51:51 +0300 | |
commit | 2a10ffbda1fabe65f9dae23dc219e9f97159bff1 (patch) | |
tree | fd3b8e0e736574b7776b518b73baa2b3d894a7dd | |
parent | Merge pull request #400 from Numerlor/issue-command-dev-contrib (diff) |
handle disabled DMs when starting Minesweeper
If the user trying to start Minesweeper has DMs disabled
then warn him in the channel where the command was
invoked.
-rw-r--r-- | bot/exts/evergreen/minesweeper.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py index ae057b30..cda9a65a 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/evergreen/minesweeper.py @@ -151,11 +151,16 @@ 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)}") + 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 (temporarily) enable DMs to receive the join code") + else: + 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, |