diff options
author | 2020-05-23 00:33:12 -0400 | |
---|---|---|
committer | 2020-05-23 00:33:12 -0400 | |
commit | 29304c07254ebdb652f402a8ca05229bc90668ae (patch) | |
tree | b9f37e023c514d3d88945ed7988b438840fbf521 | |
parent | exit minesweeper early if DM disabled (diff) | |
parent | Merge pull request #403 from Akarys42/boo-fix (diff) |
Merge branch 'master' into minesweeper-disabled-dm-handling
-rw-r--r-- | bot/__init__.py | 6 | ||||
-rw-r--r-- | bot/bot.py | 5 | ||||
-rw-r--r-- | bot/exts/evergreen/snakes/snakes_cog.py | 8 | ||||
-rw-r--r-- | bot/exts/halloween/halloweenify.py | 19 |
4 files changed, 32 insertions, 6 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()) @@ -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/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 5c433a81..a19066cf 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) |