From ff6ad8de755221a9168e59de8cda77790c46315f Mon Sep 17 00:00:00 2001 From: Matteo Bertucci Date: Mon, 4 May 2020 17:09:08 +0200 Subject: Handle staff users and DMs in the halloweenify cog The bot doesn't have enough rights to modify staff nicknames, and can't change it when it is invoked through DM neither. --- bot/exts/halloween/halloweenify.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/halloween/halloweenify.py b/bot/exts/halloween/halloweenify.py index 5c433a81..e8ec5ec7 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) + try: + if isinstance(ctx.author, discord.Member): + await ctx.author.edit(nick=nickname) + embed.description += f"Your new nickname will be: \n:ghost: **{nickname}** :jack_o_lantern:" + + 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." + ) + + 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"Although it looks like I can't change it myself, but feel free to change it yourself." + ) await ctx.send(embed=embed) -- cgit v1.2.3 From f280534d8aad8aa6b2c051be1a19685157942211 Mon Sep 17 00:00:00 2001 From: DuckMasterAl <43557963+DuckMasterAl@users.noreply.github.com> Date: Thu, 7 May 2020 21:29:26 -0400 Subject: Updated Prefix and Website --- bot/exts/evergreen/snakes/snakes_cog.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/snakes/snakes_cog.py b/bot/exts/evergreen/snakes/snakes_cog.py index 36c176ce..8a4d1603 100644 --- a/bot/exts/evergreen/snakes/snakes_cog.py +++ b/bot/exts/evergreen/snakes/snakes_cog.py @@ -945,13 +945,14 @@ 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." ) ) -- cgit v1.2.3 From 4ca9e78eb515f081d18503c9b9683e252f7a46bd Mon Sep 17 00:00:00 2001 From: DuckMasterAl <43557963+DuckMasterAl@users.noreply.github.com> Date: Thu, 7 May 2020 21:32:12 -0400 Subject: Lint limit --- bot/exts/evergreen/snakes/snakes_cog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/snakes/snakes_cog.py b/bot/exts/evergreen/snakes/snakes_cog.py index 8a4d1603..7dfb859f 100644 --- a/bot/exts/evergreen/snakes/snakes_cog.py +++ b/bot/exts/evergreen/snakes/snakes_cog.py @@ -945,7 +945,8 @@ 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://pythondiscord.com/pages/code-jams/code-jam-1-snakes-bot/). \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" -- cgit v1.2.3 From d84c9494ff20bf7680b22efe056dabee98cb04a4 Mon Sep 17 00:00:00 2001 From: kwzrd Date: Fri, 8 May 2020 20:56:55 +0200 Subject: Show bot prefix in rich presence This emulates the main bot's message for consistency. --- bot/bot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bot') 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"), +) -- cgit v1.2.3 From f1047afd7b148d4b23cc5d4b824b892b3b5e4a9c Mon Sep 17 00:00:00 2001 From: DuckMasterAl <43557963+DuckMasterAl@users.noreply.github.com> Date: Fri, 8 May 2020 19:39:56 -0400 Subject: F i x e d S p a c e --- bot/exts/evergreen/snakes/snakes_cog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/snakes/snakes_cog.py b/bot/exts/evergreen/snakes/snakes_cog.py index 7dfb859f..b3896fcd 100644 --- a/bot/exts/evergreen/snakes/snakes_cog.py +++ b/bot/exts/evergreen/snakes/snakes_cog.py @@ -951,7 +951,7 @@ class Snakes(Cog): "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> " - f"walked away as grand champions. Make sure you check out `{ctx.prefix}snakes sal` ," + 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." ) -- cgit v1.2.3 From 3f7a0a298ee469529ba9dac5af2399e28ca1e401 Mon Sep 17 00:00:00 2001 From: Matteo Bertucci Date: Sat, 9 May 2020 16:14:13 +0200 Subject: Update halloweenify error message to make it more readable and restructure the flow --- bot/exts/halloween/halloweenify.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bot') diff --git a/bot/exts/halloween/halloweenify.py b/bot/exts/halloween/halloweenify.py index e8ec5ec7..a19066cf 100644 --- a/bot/exts/halloween/halloweenify.py +++ b/bot/exts/halloween/halloweenify.py @@ -41,21 +41,21 @@ class Halloweenify(commands.Cog): ) embed.set_image(url=image) - try: - if isinstance(ctx.author, discord.Member): + 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:" - else: # The command has been invoked in DM + 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"Feel free to change it yourself, or invoke the command again inside the server." + f"It looks like I cannot change your name, but feel free to change it yourself." ) - except Forbidden: # The bot doesn't have enough permission + 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"Although it looks like I can't change it myself, but feel free to change it yourself." + f"Feel free to change it yourself, or invoke the command again inside the server." ) await ctx.send(embed=embed) -- cgit v1.2.3 From 540f98c8f2e890061884c70c62f38d9cfa64beff Mon Sep 17 00:00:00 2001 From: Numerlor <25886452+Numerlor@users.noreply.github.com> Date: Sun, 17 May 2020 23:31:00 +0200 Subject: Set ayncio event loop to Selector on windows. Python 3.8 set the default asyncio event loop on windows to Proactor, which is not supported in aiodns. Co-authored-by: MarkKoz --- bot/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bot') 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()) -- cgit v1.2.3