From bf1901eba73f7f7d3ea39cf3db6c1ecf5195e321 Mon Sep 17 00:00:00 2001 From: sco1 Date: Sat, 11 May 2019 21:24:26 -0400 Subject: Fix broken help getter patterns Utilize new ctx.send_help coro Bump d.py minor version & relock --- bot/seasons/christmas/adventofcode.py | 2 +- bot/seasons/evergreen/snakes/snakes_cog.py | 9 +-------- bot/seasons/season.py | 2 +- bot/seasons/valentines/be_my_valentine.py | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) (limited to 'bot') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 5d05dce6..075c5606 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -132,7 +132,7 @@ class AdventOfCode(commands.Cog): async def adventofcode_group(self, ctx: commands.Context): """All of the Advent of Code commands.""" - await ctx.invoke(self.bot.get_command("help"), "adventofcode") + await ctx.send_help(ctx.command) @adventofcode_group.command( name="subscribe", diff --git a/bot/seasons/evergreen/snakes/snakes_cog.py b/bot/seasons/evergreen/snakes/snakes_cog.py index 3ffdf1bf..b5fb2881 100644 --- a/bot/seasons/evergreen/snakes/snakes_cog.py +++ b/bot/seasons/evergreen/snakes/snakes_cog.py @@ -458,7 +458,7 @@ class Snakes(Cog): async def snakes_group(self, ctx: Context): """Commands from our first code jam.""" - await ctx.invoke(self.bot.get_command("help"), "snake") + await ctx.send_help(ctx.command) @bot_has_permissions(manage_messages=True) @snakes_group.command(name='antidote') @@ -1055,13 +1055,6 @@ class Snakes(Cog): ) await ctx.channel.send(embed=embed) - @snakes_group.command(name='help') - async def help_command(self, ctx: Context): - """Invokes the help command for the Snakes Cog.""" - - log.debug(f"{ctx.author} requested info about the snakes cog") - return await ctx.invoke(self.bot.get_command("help"), "Snakes") - @snakes_group.command(name='snakify') async def snakify_command(self, ctx: Context, *, message: str = None): """ diff --git a/bot/seasons/season.py b/bot/seasons/season.py index 6d992276..6d99b77f 100644 --- a/bot/seasons/season.py +++ b/bot/seasons/season.py @@ -442,7 +442,7 @@ class SeasonManager(commands.Cog): async def refresh(self, ctx): """Refreshes certain seasonal elements without reloading seasons.""" if not ctx.invoked_subcommand: - await ctx.invoke(bot.get_command("help"), "refresh") + await ctx.send_help(ctx.command) @refresh.command(name="avatar") async def refresh_avatar(self, ctx): diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 55c4adb1..5ff5857b 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -42,7 +42,7 @@ class BeMyValentine(commands.Cog): 2) use the command \".lovefest unsub\" to get rid of the lovefest role. """ - await ctx.invoke(self.bot.get_command("help"), "lovefest") + await ctx.send_help(ctx.command) @lovefest_role.command(name="sub") async def add_role(self, ctx): -- cgit v1.2.3 From 9890f64206771d715b7f3829f4d5a8d60c256631 Mon Sep 17 00:00:00 2001 From: sco1 Date: Sat, 11 May 2019 22:12:44 -0400 Subject: Fix broken avatar URL getter patterns avatar_url_as now returns an Asset object, which cannot be passed directly to aiohttp since it's expecting a string. Asset objects also provide a read method, returning the bytes directly so the aiohttp call is no longer necessary. --- bot/seasons/easter/avatar_easterifier.py | 3 +-- bot/seasons/evergreen/snakes/utils.py | 14 ++++++-------- bot/seasons/halloween/spookyavatar.py | 5 +++-- 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'bot') diff --git a/bot/seasons/easter/avatar_easterifier.py b/bot/seasons/easter/avatar_easterifier.py index 9f7ea271..a84e5eb4 100644 --- a/bot/seasons/easter/avatar_easterifier.py +++ b/bot/seasons/easter/avatar_easterifier.py @@ -71,8 +71,7 @@ class AvatarEasterifier(commands.Cog): async with ctx.typing(): # Grabs image of avatar - async with self.bot.http_session.get(ctx.author.avatar_url_as(size=256)) as resp: - image_bytes = await resp.read() + image_bytes = await ctx.author.avatar_url_as(size=256).read() old = Image.open(BytesIO(image_bytes)) old = old.convert("RGBA") diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py index e2ed60bd..01e527ca 100644 --- a/bot/seasons/evergreen/snakes/utils.py +++ b/bot/seasons/evergreen/snakes/utils.py @@ -8,7 +8,6 @@ from itertools import product from pathlib import Path from typing import List, Tuple -import aiohttp from PIL import Image from PIL.ImageDraw import ImageDraw from discord import File, Member, Reaction @@ -480,18 +479,17 @@ class SnakeAndLaddersGame: async def _add_player(self, user: Member): self.players.append(user) self.player_tiles[user.id] = 1 - avatar_url = user.avatar_url_as(format='jpeg', size=PLAYER_ICON_IMAGE_SIZE) - async with aiohttp.ClientSession() as session: - async with session.get(avatar_url) as res: - avatar_bytes = await res.read() - im = Image.open(io.BytesIO(avatar_bytes)).resize((BOARD_PLAYER_SIZE, BOARD_PLAYER_SIZE)) - self.avatar_images[user.id] = im + + avatar_bytes = await user.avatar_url_as(format='jpeg', size=PLAYER_ICON_IMAGE_SIZE).read() + im = Image.open(io.BytesIO(avatar_bytes)).resize((BOARD_PLAYER_SIZE, BOARD_PLAYER_SIZE)) + self.avatar_images[user.id] = im async def player_join(self, user: Member): """ Handle players joining the game. - Prevent player joining if they have already joined, if the game is full, or if the game is + Prevent player joining if they have already cccccckgctrfebkrntucrvrktivvefvdjvnnniiehbde + joined, if the game is full, or if the game is in a waiting state. """ diff --git a/bot/seasons/halloween/spookyavatar.py b/bot/seasons/halloween/spookyavatar.py index 15c7c431..2cc81da8 100644 --- a/bot/seasons/halloween/spookyavatar.py +++ b/bot/seasons/halloween/spookyavatar.py @@ -37,8 +37,9 @@ class SpookyAvatar(commands.Cog): embed = discord.Embed(colour=0xFF0000) embed.title = "Is this you or am I just really paranoid?" embed.set_author(name=str(user.name), icon_url=user.avatar_url) - resp = await self.get(user.avatar_url) - im = Image.open(BytesIO(resp)) + + image_bytes = await ctx.author.avatar_url.read() + im = Image.open(BytesIO(image_bytes)) modified_im = spookifications.get_random_effect(im) modified_im.save(str(ctx.message.id)+'.png') f = discord.File(str(ctx.message.id)+'.png') -- cgit v1.2.3 From 4d250ffa79562034993bf29c6c27ed9df755f264 Mon Sep 17 00:00:00 2001 From: sco1 Date: Sat, 11 May 2019 23:44:36 -0400 Subject: Revert cat-induced programming trauma --- bot/seasons/evergreen/snakes/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py index 01e527ca..a7cb70a7 100644 --- a/bot/seasons/evergreen/snakes/utils.py +++ b/bot/seasons/evergreen/snakes/utils.py @@ -488,8 +488,7 @@ class SnakeAndLaddersGame: """ Handle players joining the game. - Prevent player joining if they have already cccccckgctrfebkrntucrvrktivvefvdjvnnniiehbde - joined, if the game is full, or if the game is + Prevent player joining if they have already joined, if the game is full, or if the game is in a waiting state. """ -- cgit v1.2.3