From f12940261d7afd7254c703d30272fdc688cb8ef7 Mon Sep 17 00:00:00 2001 From: Marko Kovačević Date: Tue, 9 Oct 2018 11:42:09 +0200 Subject: Implement Halloweenify feature. --- bot/cogs/halloweenify.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 bot/cogs/halloweenify.py (limited to 'bot/cogs/halloweenify.py') diff --git a/bot/cogs/halloweenify.py b/bot/cogs/halloweenify.py new file mode 100644 index 00000000..0422e787 --- /dev/null +++ b/bot/cogs/halloweenify.py @@ -0,0 +1,46 @@ +from pathlib import Path +from json import load +from random import choice + + +import discord +from discord.ext import commands +from discord.ext.commands.cooldowns import BucketType + + +class Halloweenify: + + """ + A cog to change a invokers nickname to a spooky one! + """ + + def __init__(self, bot): + self.bot = bot + + @commands.cooldown(1, 300, BucketType.user) + @commands.command() + async def halloweenify(self, ctx): + with open(Path('../bot/resources', '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 = 'Wow!' + embed.description = ( + f'Your previous nickname, **{ctx.author.display_name}**, wasn\'t spooky enough for you that you have ' + f'decided to change it?! Okay, your new nickname will be **{nickname}**.\n\n' + ) + embed.set_image(url=image) + + await ctx.author.edit(nick=nickname) + await ctx.send(embed=embed) + + +def setup(bot): + bot.add_cog(Halloweenify(bot)) -- cgit v1.2.3 From a4c8da298b4b44fe222b304676029407734c77f6 Mon Sep 17 00:00:00 2001 From: Marko Kovačević Date: Wed, 10 Oct 2018 11:04:24 +0200 Subject: Change message to a more friendly one. --- bot/cogs/halloweenify.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bot/cogs/halloweenify.py') diff --git a/bot/cogs/halloweenify.py b/bot/cogs/halloweenify.py index 0422e787..58cef019 100644 --- a/bot/cogs/halloweenify.py +++ b/bot/cogs/halloweenify.py @@ -33,8 +33,9 @@ class Halloweenify: embed.colour = discord.Colour.dark_orange() embed.title = 'Wow!' embed.description = ( - f'Your previous nickname, **{ctx.author.display_name}**, wasn\'t spooky enough for you that you have ' - f'decided to change it?! Okay, your new nickname will be **{nickname}**.\n\n' + 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 Your ' + f'new nickname will be: \n 👻 **{nickname}** 🎃' ) embed.set_image(url=image) -- cgit v1.2.3 From 94a275c3b0222a261aa7d07b8ab37f92f9d82fd3 Mon Sep 17 00:00:00 2001 From: Marko Kovačević Date: Wed, 10 Oct 2018 11:18:55 +0200 Subject: Minor changes to the Embed. --- bot/cogs/halloweenify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot/cogs/halloweenify.py') diff --git a/bot/cogs/halloweenify.py b/bot/cogs/halloweenify.py index 58cef019..c49e0058 100644 --- a/bot/cogs/halloweenify.py +++ b/bot/cogs/halloweenify.py @@ -31,11 +31,11 @@ class Halloweenify: # Build up a Embed embed = discord.Embed() embed.colour = discord.Colour.dark_orange() - embed.title = 'Wow!' + 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 Your ' - f'new nickname will be: \n 👻 **{nickname}** 🎃' + f'new nickname will be: \n :jack_o_lantern: **{nickname}** :ghost:' ) embed.set_image(url=image) -- cgit v1.2.3 From 8ea196581e70e149ce998d9c49bf8bf1f9a746db Mon Sep 17 00:00:00 2001 From: Marko Kovačević Date: Wed, 10 Oct 2018 11:21:50 +0200 Subject: Ooops, reversed the emojis. --- bot/cogs/halloweenify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/cogs/halloweenify.py') diff --git a/bot/cogs/halloweenify.py b/bot/cogs/halloweenify.py index c49e0058..226d55db 100644 --- a/bot/cogs/halloweenify.py +++ b/bot/cogs/halloweenify.py @@ -35,7 +35,7 @@ class Halloweenify: 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 Your ' - f'new nickname will be: \n :jack_o_lantern: **{nickname}** :ghost:' + f'new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:' ) embed.set_image(url=image) -- cgit v1.2.3 From ff5882981e0fcaba65f8b6ffa0dcbdd756826503 Mon Sep 17 00:00:00 2001 From: Marko Kovačević Date: Wed, 10 Oct 2018 11:26:59 +0200 Subject: Missing newline. --- bot/cogs/halloweenify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/cogs/halloweenify.py') diff --git a/bot/cogs/halloweenify.py b/bot/cogs/halloweenify.py index 226d55db..e4fb787c 100644 --- a/bot/cogs/halloweenify.py +++ b/bot/cogs/halloweenify.py @@ -35,7 +35,7 @@ class Halloweenify: 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 Your ' - f'new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:' + f'new nickname will be: \n\n :ghost: **{nickname}** :jack_o_lantern:' ) embed.set_image(url=image) -- cgit v1.2.3 From fb46d8f2dba8a5f00bf7914c8b4a026acbbf55fc Mon Sep 17 00:00:00 2001 From: Marko Kovačević Date: Wed, 10 Oct 2018 11:28:46 +0200 Subject: Another cosmetic mistake. --- bot/cogs/halloweenify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot/cogs/halloweenify.py') diff --git a/bot/cogs/halloweenify.py b/bot/cogs/halloweenify.py index e4fb787c..8a9db3df 100644 --- a/bot/cogs/halloweenify.py +++ b/bot/cogs/halloweenify.py @@ -34,8 +34,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 Your ' - f'new nickname will be: \n\n :ghost: **{nickname}** :jack_o_lantern:' + 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) -- cgit v1.2.3