aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar JosuĂ© D. (JD) <[email protected]>2020-05-24 20:18:56 -0400
committerGravatar GitHub <[email protected]>2020-05-24 20:18:56 -0400
commit2defff0491ad15dcb692c3a60b74662378d472bd (patch)
tree346f8e57933423d086c66a512692f2615e101065
parent5/24 - bot utils - added encoding, and notes for persist (diff)
parentMerge pull request #401 from fuzzmz/minesweeper-disabled-dm-handling (diff)
Merge branch 'master' into encoding_bug_fix
-rw-r--r--bot/__init__.py6
-rw-r--r--bot/bot.py5
-rw-r--r--bot/exts/evergreen/minesweeper.py17
-rw-r--r--bot/exts/evergreen/snakes/snakes_cog.py8
-rw-r--r--bot/exts/halloween/halloweenify.py19
5 files changed, 43 insertions, 12 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index 4729e50c..6976e089 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -1,3 +1,4 @@
+import asyncio
import logging
import logging.handlers
import os
@@ -63,3 +64,8 @@ logging.basicConfig(
handlers=[console_handler, file_handler]
)
logging.getLogger().info('Logging initialization complete')
+
+
+# On Windows, the selector event loop is required for aiodns.
+if os.name == "nt":
+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
diff --git a/bot/bot.py b/bot/bot.py
index b0162377..39ed8bbe 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -203,4 +203,7 @@ class SeasonalBot(commands.Bot):
await self._guild_available.wait()
-bot = SeasonalBot(command_prefix=Client.prefix)
+bot = SeasonalBot(
+ command_prefix=Client.prefix,
+ activity=discord.Game(name=f"Commands: {Client.prefix}help"),
+)
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,
diff --git a/bot/exts/evergreen/snakes/snakes_cog.py b/bot/exts/evergreen/snakes/snakes_cog.py
index 36c176ce..b3896fcd 100644
--- a/bot/exts/evergreen/snakes/snakes_cog.py
+++ b/bot/exts/evergreen/snakes/snakes_cog.py
@@ -945,13 +945,15 @@ class Snakes(Cog):
title="About the snake cog",
description=(
"The features in this cog were created by members of the community "
- "during our first ever [code jam event](https://gitlab.com/discord-python/code-jams/code-jam-1). \n\n"
+ "during our first ever "
+ "[code jam event](https://pythondiscord.com/pages/code-jams/code-jam-1-snakes-bot/). \n\n"
"The event saw over 50 participants, who competed to write a discord bot cog with a snake theme over "
"48 hours. The staff then selected the best features from all the best teams, and made modifications "
"to ensure they would all work together before integrating them into the community bot.\n\n"
"It was a tight race, but in the end, <@!104749643715387392> and <@!303940835005825024> "
- "walked away as grand champions. Make sure you check out `!snakes sal`, `!snakes draw` "
- "and `!snakes hatch` to see what they came up with."
+ f"walked away as grand champions. Make sure you check out `{ctx.prefix}snakes sal`,"
+ f"`{ctx.prefix}snakes draw` and `{ctx.prefix}snakes hatch` "
+ "to see what they came up with."
)
)
diff --git a/bot/exts/halloween/halloweenify.py b/bot/exts/halloween/halloweenify.py
index aae7590a..596c6682 100644
--- a/bot/exts/halloween/halloweenify.py
+++ b/bot/exts/halloween/halloweenify.py
@@ -4,6 +4,7 @@ from pathlib import Path
from random import choice
import discord
+from discord.errors import Forbidden
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
@@ -37,11 +38,25 @@ class Halloweenify(commands.Cog):
f"**{ctx.author.display_name}** wasn\'t spooky enough for you? That\'s understandable, "
f"{ctx.author.display_name} isn\'t scary at all! "
"Let me think of something better. Hmm... I got it!\n\n "
- f"Your new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:"
)
embed.set_image(url=image)
- await ctx.author.edit(nick=nickname)
+ if isinstance(ctx.author, discord.Member):
+ try:
+ await ctx.author.edit(nick=nickname)
+ embed.description += f"Your new nickname will be: \n:ghost: **{nickname}** :jack_o_lantern:"
+
+ except Forbidden: # The bot doesn't have enough permission
+ embed.description += (
+ f"Your new nickname should be: \n :ghost: **{nickname}** :jack_o_lantern: \n\n"
+ f"It looks like I cannot change your name, but feel free to change it yourself."
+ )
+
+ else: # The command has been invoked in DM
+ embed.description += (
+ f"Your new nickname should be: \n :ghost: **{nickname}** :jack_o_lantern: \n\n"
+ f"Feel free to change it yourself, or invoke the command again inside the server."
+ )
await ctx.send(embed=embed)