From 44825f97ea399fc077ec2d964d1a6c9da2069fed Mon Sep 17 00:00:00 2001 From: sco1 Date: Tue, 20 Nov 2018 15:45:53 -0500 Subject: Add typing context manager where appropriate Some minor syntax & logic fixes where noticed --- bot/cogs/hacktober/spookyavatar.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'bot/cogs/hacktober/spookyavatar.py') diff --git a/bot/cogs/hacktober/spookyavatar.py b/bot/cogs/hacktober/spookyavatar.py index ad8a9242..abfa1565 100644 --- a/bot/cogs/hacktober/spookyavatar.py +++ b/bot/cogs/hacktober/spookyavatar.py @@ -35,15 +35,17 @@ class SpookyAvatar: if user is None: user = ctx.message.author - 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)) - modified_im = spookifications.get_random_effect(im) - modified_im.save(str(ctx.message.id)+'.png') - f = discord.File(str(ctx.message.id)+'.png') - embed.set_image(url='attachment://'+str(ctx.message.id)+'.png') + async with ctx.typing(): + 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)) + modified_im = spookifications.get_random_effect(im) + modified_im.save(str(ctx.message.id)+'.png') + f = discord.File(str(ctx.message.id)+'.png') + embed.set_image(url='attachment://'+str(ctx.message.id)+'.png') + await ctx.send(file=f, embed=embed) os.remove(str(ctx.message.id)+'.png') -- cgit v1.2.3 From 401126ef8d8f7955be835096791c980248145231 Mon Sep 17 00:00:00 2001 From: sco1 Date: Tue, 20 Nov 2018 15:49:33 -0500 Subject: Resolve Flake8 --- bot/cogs/hacktober/halloweenify.py | 3 ++- bot/cogs/hacktober/monstersurvey.py | 10 ++++++---- bot/cogs/hacktober/spookyavatar.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'bot/cogs/hacktober/spookyavatar.py') diff --git a/bot/cogs/hacktober/halloweenify.py b/bot/cogs/hacktober/halloweenify.py index 57ed9390..5d270974 100644 --- a/bot/cogs/hacktober/halloweenify.py +++ b/bot/cogs/hacktober/halloweenify.py @@ -36,7 +36,8 @@ class Halloweenify: embed.title = 'Not spooky enough?' embed.description = ( 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'{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) diff --git a/bot/cogs/hacktober/monstersurvey.py b/bot/cogs/hacktober/monstersurvey.py index dd869634..2b78abc6 100644 --- a/bot/cogs/hacktober/monstersurvey.py +++ b/bot/cogs/hacktober/monstersurvey.py @@ -110,7 +110,7 @@ class MonsterSurvey: name = self.get_name_by_leaderboard_index(idx) except ValueError: name = name.lower() - + vote_embed = Embed( name='Monster Voting', color=0xFF6800 @@ -164,7 +164,7 @@ class MonsterSurvey: name = self.get_name_by_leaderboard_index(idx) except ValueError: name = name.lower() - + m = self.voter_registry.get(name) if not m: await ctx.send('That monster does not exist.') @@ -199,11 +199,13 @@ class MonsterSurvey: votes = len(vr[m]['votes']) percentage = ((votes / total_votes) * 100) if total_votes > 0 else 0 embed.add_field(name=f"{rank+1}. {vr[m]['full_name']}", - value=f"{votes} votes. {percentage:.1f}% of total votes.\n" + value=( + f"{votes} votes. {percentage:.1f}% of total votes.\n" f"Vote for this monster by typing " f"'.monster vote {m}'\n" f"Get more information on this monster by typing " - f"'.monster show {m}'", + f"'.monster show {m}'" + ), inline=False) embed.set_footer(text="You can also vote by their rank number. '.monster vote {number}' ") diff --git a/bot/cogs/hacktober/spookyavatar.py b/bot/cogs/hacktober/spookyavatar.py index abfa1565..6ce4471c 100644 --- a/bot/cogs/hacktober/spookyavatar.py +++ b/bot/cogs/hacktober/spookyavatar.py @@ -45,7 +45,7 @@ class SpookyAvatar: modified_im.save(str(ctx.message.id)+'.png') f = discord.File(str(ctx.message.id)+'.png') embed.set_image(url='attachment://'+str(ctx.message.id)+'.png') - + await ctx.send(file=f, embed=embed) os.remove(str(ctx.message.id)+'.png') -- cgit v1.2.3