diff options
author | 2021-08-31 15:01:10 +0200 | |
---|---|---|
committer | 2021-08-31 15:01:10 +0200 | |
commit | ffda1f7069065fd4ce2b2fe781fbcb5793406f99 (patch) | |
tree | 0a68152f289f4fd1a78386a3313d5cbce584bdfe /bot | |
parent | Merge pull request #831 from brad90four/patch-1 (diff) |
Migrate to Discord.py 2.0a0
Since the Discord.py repository has been archived, we can switch to the latest commit of 2.0a0, knowing no breaking change will occur (still pinned to the commit just in case).
This commit also solves two small problems due to that fix, the avatar interface changing and Embed.name disappearing. Quite a painless migration.
Diffstat (limited to 'bot')
-rw-r--r-- | bot/bot.py | 2 | ||||
-rw-r--r-- | bot/exts/easter/egg_decorating.py | 2 | ||||
-rw-r--r-- | bot/exts/evergreen/avatar_modification/avatar_modify.py | 26 | ||||
-rw-r--r-- | bot/exts/evergreen/bookmark.py | 2 | ||||
-rw-r--r-- | bot/exts/evergreen/recommend_game.py | 2 | ||||
-rw-r--r-- | bot/exts/evergreen/snakes/_converter.py | 2 | ||||
-rw-r--r-- | bot/exts/evergreen/snakes/_snakes_cog.py | 14 | ||||
-rw-r--r-- | bot/exts/evergreen/snakes/_utils.py | 2 | ||||
-rw-r--r-- | bot/exts/utils/extensions.py | 2 |
9 files changed, 24 insertions, 30 deletions
@@ -120,7 +120,7 @@ class Bot(commands.Bot): return if not icon: - icon = self.user.avatar_url_as(format="png") + icon = self.user.display_avatar.url embed = Embed(description=details) embed.set_author(name=title, icon_url=icon) diff --git a/bot/exts/easter/egg_decorating.py b/bot/exts/easter/egg_decorating.py index fd7620d4..6201d424 100644 --- a/bot/exts/easter/egg_decorating.py +++ b/bot/exts/easter/egg_decorating.py @@ -108,7 +108,7 @@ class EggDecorating(commands.Cog): description="Here is your pretty little egg. Hope you like it!" ) embed.set_image(url="attachment://egg.png") - embed.set_footer(text=f"Made by {ctx.author.display_name}", icon_url=ctx.author.avatar_url) + embed.set_footer(text=f"Made by {ctx.author.display_name}", icon_url=ctx.author.display_avatar.url) await ctx.send(file=file, embed=embed) return new_im diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 7b4ae9c7..fd586613 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -100,7 +100,7 @@ class AvatarModify(commands.Cog): await ctx.send(f"{Emojis.cross_mark} Could not get user info.") return - image_bytes = await user.avatar_url_as(size=1024).read() + image_bytes = await user.display_avatar.replace(size=1024).read() file_name = file_safe_name("eightbit_avatar", ctx.author.display_name) file = await in_executor( @@ -116,7 +116,7 @@ class AvatarModify(commands.Cog): ) embed.set_image(url=f"attachment://{file_name}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.display_avatar.url) await ctx.send(embed=embed, file=file) @@ -137,7 +137,7 @@ class AvatarModify(commands.Cog): await ctx.send(f"{Emojis.cross_mark} Could not get user info.") return - image_bytes = await user.avatar_url_as(size=1024).read() + image_bytes = await user.display_avatar.replace(size=1024).read() filename = file_safe_name("reverse_avatar", ctx.author.display_name) file = await in_executor( @@ -153,7 +153,7 @@ class AvatarModify(commands.Cog): ) embed.set_image(url=f"attachment://{filename}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.display_avatar.url) await ctx.send(embed=embed, file=file) @@ -193,7 +193,7 @@ class AvatarModify(commands.Cog): return ctx.send = send_message # Reassigns ctx.send - image_bytes = await user.avatar_url_as(size=256).read() + image_bytes = await user.display_avatar.replace(size=256).read() file_name = file_safe_name("easterified_avatar", ctx.author.display_name) file = await in_executor( @@ -205,11 +205,11 @@ class AvatarModify(commands.Cog): ) embed = discord.Embed( - name="Your Lovely Easterified Avatar!", + title="Your Lovely Easterified Avatar!", description="Here is your lovely avatar, all bright and colourful\nwith Easter pastel colours. Enjoy :D" ) embed.set_image(url=f"attachment://{file_name}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.display_avatar.url) await ctx.send(file=file, embed=embed) @@ -235,7 +235,7 @@ class AvatarModify(commands.Cog): ) embed = discord.Embed( - name="Your Lovely Pride Avatar!", + title="Your Lovely Pride Avatar!", description=f"Here is your lovely avatar, surrounded by\n a beautiful {option} flag. Enjoy :D" ) embed.set_image(url=f"attachment://{file_name}") @@ -268,7 +268,7 @@ class AvatarModify(commands.Cog): if not user: await ctx.send(f"{Emojis.cross_mark} Could not get user info.") return - image_bytes = await user.avatar_url_as(size=1024).read() + image_bytes = await user.display_avatar.replace(size=1024).read() await self.send_pride_image(ctx, image_bytes, pixels, flag, option) @prideavatar.command() @@ -296,7 +296,7 @@ class AvatarModify(commands.Cog): return async with ctx.typing(): - image_bytes = await user.avatar_url_as(size=1024).read() + image_bytes = await user.display_avatar.replace(size=1024).read() file_name = file_safe_name("spooky_avatar", ctx.author.display_name) @@ -312,7 +312,7 @@ class AvatarModify(commands.Cog): colour=Colours.soft_red ) embed.set_image(url=f"attachment://{file_name}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=ctx.author.avatar_url) + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=ctx.author.display_avatar.url) await ctx.send(file=file, embed=embed) @@ -335,7 +335,7 @@ class AvatarModify(commands.Cog): file_name = file_safe_name("mosaic_avatar", ctx.author.display_name) - img_bytes = await user.avatar_url_as(size=1024).read() + img_bytes = await user.display_avatar.replace(size=1024).read() file = await in_executor( PfpEffects.apply_effect, @@ -362,7 +362,7 @@ class AvatarModify(commands.Cog): ) embed.set_image(url=f"attachment://{file_name}") - embed.set_footer(text=f"Made by {ctx.author.display_name}", icon_url=user.avatar_url) + embed.set_footer(text=f"Made by {ctx.author.display_name}", icon_url=user.display_avatar.url) await ctx.send(file=file, embed=embed) diff --git a/bot/exts/evergreen/bookmark.py b/bot/exts/evergreen/bookmark.py index f93371a6..98b0f2bf 100644 --- a/bot/exts/evergreen/bookmark.py +++ b/bot/exts/evergreen/bookmark.py @@ -37,7 +37,7 @@ class Bookmark(commands.Cog): name="Wanna give it a visit?", value=f"[Visit original message]({target_message.jump_url})" ) - embed.set_author(name=target_message.author, icon_url=target_message.author.avatar_url) + embed.set_author(name=target_message.author, icon_url=target_message.author.display_avatar.url) embed.set_thumbnail(url=Icons.bookmark) return embed diff --git a/bot/exts/evergreen/recommend_game.py b/bot/exts/evergreen/recommend_game.py index 35d60128..66597b59 100644 --- a/bot/exts/evergreen/recommend_game.py +++ b/bot/exts/evergreen/recommend_game.py @@ -39,7 +39,7 @@ class RecommendGame(commands.Cog): # Creating and formatting Embed embed = discord.Embed(color=discord.Colour.blue()) if author is not None: - embed.set_author(name=author.name, icon_url=author.avatar_url) + embed.set_author(name=author.name, icon_url=author.display_avatar.url) embed.set_image(url=game["image"]) embed.add_field(name=f"Recommendation: {game['title']}\n{game['link']}", value=game["description"]) diff --git a/bot/exts/evergreen/snakes/_converter.py b/bot/exts/evergreen/snakes/_converter.py index c8d1909b..75212107 100644 --- a/bot/exts/evergreen/snakes/_converter.py +++ b/bot/exts/evergreen/snakes/_converter.py @@ -53,7 +53,7 @@ class Snake(Converter): embed = discord.Embed( title="Found multiple choices. Please choose the correct one.", colour=0x59982F) - embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) + embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.display_avatar.url) name = await disambiguate(ctx, get_potential(all_names), timeout=timeout, embed=embed) return names.get(name, name) diff --git a/bot/exts/evergreen/snakes/_snakes_cog.py b/bot/exts/evergreen/snakes/_snakes_cog.py index 07d3c363..225df948 100644 --- a/bot/exts/evergreen/snakes/_snakes_cog.py +++ b/bot/exts/evergreen/snakes/_snakes_cog.py @@ -486,7 +486,7 @@ class Snakes(Cog): win = False antidote_embed = Embed(color=SNAKE_COLOR, title="Antidote") - antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) + antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.display_avatar.url) # Generate answer antidote_answer = list(ANTIDOTE_EMOJI) # Duplicate list, not reference it @@ -569,7 +569,7 @@ class Snakes(Cog): # Winning / Ending Screen if win is True: antidote_embed = Embed(color=SNAKE_COLOR, title="Antidote") - antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) + antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.display_avatar.url) antidote_embed.set_image(url="https://i.makeagif.com/media/7-12-2015/Cj1pts.gif") antidote_embed.add_field(name="You have created the snake antidote!", value=f"The solution was: {' '.join(antidote_answer)}\n" @@ -577,7 +577,7 @@ class Snakes(Cog): await board_id.edit(embed=antidote_embed) else: antidote_embed = Embed(color=SNAKE_COLOR, title="Antidote") - antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) + antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.display_avatar.url) antidote_embed.set_image(url="https://media.giphy.com/media/ceeN6U57leAhi/giphy.gif") antidote_embed.add_field( name=EMPTY_UNICODE, @@ -1063,16 +1063,10 @@ class Snakes(Cog): message = self._get_random_long_message(messages) - # Set the avatar - if user.avatar is not None: - avatar = f"https://cdn.discordapp.com/avatars/{user.id}/{user.avatar}" - else: - avatar = ctx.author.default_avatar_url - # Build and send the embed embed.set_author( name=f"{user.name}#{user.discriminator}", - icon_url=avatar, + icon_url=user.display_avatar.url, ) embed.description = f"*{self._snakify(message)}*" diff --git a/bot/exts/evergreen/snakes/_utils.py b/bot/exts/evergreen/snakes/_utils.py index f996d7f8..55acaf1f 100644 --- a/bot/exts/evergreen/snakes/_utils.py +++ b/bot/exts/evergreen/snakes/_utils.py @@ -461,7 +461,7 @@ class SnakeAndLaddersGame: self.players.append(user) self.player_tiles[user.id] = 1 - avatar_bytes = await user.avatar_url_as(format="jpeg", size=PLAYER_ICON_IMAGE_SIZE).read() + avatar_bytes = await user.display_avatar.read() im = Image.open(io.BytesIO(avatar_bytes)).resize((BOARD_PLAYER_SIZE, BOARD_PLAYER_SIZE)) self.avatar_images[user.id] = im diff --git a/bot/exts/utils/extensions.py b/bot/exts/utils/extensions.py index 64e404d2..a95def4e 100644 --- a/bot/exts/utils/extensions.py +++ b/bot/exts/utils/extensions.py @@ -155,7 +155,7 @@ class Extensions(commands.Cog): embed.set_author( name="Extensions List", url=Client.github_bot_repo, - icon_url=str(self.bot.user.avatar_url) + icon_url=str(self.bot.user.display_avatar.url) ) lines = [] |