aboutsummaryrefslogtreecommitdiffstats
path: root/bot/cogs/halloweenify.py
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2018-10-10 11:31:48 +0200
committerGravatar GitHub <[email protected]>2018-10-10 11:31:48 +0200
commitb3b8283c0d557895f98921f7129d6d14a8ae36fe (patch)
treece2342405a84496b7db1a0b937ec4bea98e671bf /bot/cogs/halloweenify.py
parentMerge pull request #23 from rgables/master (diff)
parentAnother cosmetic mistake. (diff)
Merge pull request #34 from markylon/master
Implement Halloweenify feature.
Diffstat (limited to 'bot/cogs/halloweenify.py')
-rw-r--r--bot/cogs/halloweenify.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/bot/cogs/halloweenify.py b/bot/cogs/halloweenify.py
new file mode 100644
index 00000000..8a9db3df
--- /dev/null
+++ b/bot/cogs/halloweenify.py
@@ -0,0 +1,47 @@
+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 = '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)
+
+
+def setup(bot):
+ bot.add_cog(Halloweenify(bot))