diff options
author | 2018-11-20 15:45:53 -0500 | |
---|---|---|
committer | 2018-11-20 15:45:53 -0500 | |
commit | 44825f97ea399fc077ec2d964d1a6c9da2069fed (patch) | |
tree | 008b24bc7cf84a95b638bdacc73a9ec195ea330a /bot/cogs/hacktober/halloweenify.py | |
parent | Merge branch 'markylon-gif' (diff) |
Add typing context manager where appropriate
Some minor syntax & logic fixes where noticed
Diffstat (limited to 'bot/cogs/hacktober/halloweenify.py')
-rw-r--r-- | bot/cogs/hacktober/halloweenify.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/bot/cogs/hacktober/halloweenify.py b/bot/cogs/hacktober/halloweenify.py index 9b93ac99..57ed9390 100644 --- a/bot/cogs/hacktober/halloweenify.py +++ b/bot/cogs/hacktober/halloweenify.py @@ -21,26 +21,28 @@ class Halloweenify: """ Change your nickname into a much spookier one! """ - with open(Path('bot', 'resources', 'halloween', 'halloweenify.json'), 'r') as f: - data = load(f) - - # Choose a random character from our list we loaded above and set apart the nickname and image url. - character = choice(data['characters']) - nickname = ''.join([nickname for nickname in character]) - image = ''.join([character[nickname] for nickname in character]) - - # Build up a Embed - embed = discord.Embed() - embed.colour = discord.Colour.dark_orange() - 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'Your new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:' - ) - embed.set_image(url=image) - - await ctx.author.edit(nick=nickname) + async with ctx.typing(): + with open(Path('bot', 'resources', 'halloween', 'halloweenify.json'), 'r') as f: + data = load(f) + + # Choose a random character from our list we loaded above and set apart the nickname and image url. + character = choice(data['characters']) + nickname = ''.join([nickname for nickname in character]) + image = ''.join([character[nickname] for nickname in character]) + + # Build up a Embed + embed = discord.Embed() + embed.colour = discord.Colour.dark_orange() + 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'Your new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:' + ) + embed.set_image(url=image) + + await ctx.author.edit(nick=nickname) + await ctx.send(embed=embed) |