From a84cdda8acc1d01f16d5ecd9f3fa8ffe33374136 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 8 Jun 2020 21:43:31 +0100 Subject: [PATCH] Added lemon command --- cogs/FunCommands.py | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/cogs/FunCommands.py b/cogs/FunCommands.py index 682f1484..3ef7e8bc 100644 --- a/cogs/FunCommands.py +++ b/cogs/FunCommands.py @@ -169,6 +169,40 @@ class Fun(commands.Cog): except FileNotFoundError as e: print(e) + @commands.command(aliases=["lem", "Lemon", "Lem"]) + @cooldown(1, 2, BucketType.channel) + async def lemon(self, ctx, target: discord.Member): + + channels = ["bot-commands", "picto-chat", "general"] + + try: + if str(ctx.channel) in channels: + + # set member as the author + member = ctx.message.author + userAvatar = member.avatar_url + + embed = discord.Embed( + title=f" | **{member.display_name}** Gives A Lemon To **{target.display_name}**", + colour=discord.Colour(int(random.choice(colours)))) + embed.set_image( + url="https://media.discordapp.net/attachments/718484280925224981/719629805263257630/lemon.gif") + embed.set_footer(text=f"Requested by {ctx.message.author}", icon_url='{}'.format(userAvatar)) + embed.timestamp = datetime.datetime.utcnow() + + await ctx.send(embed=embed) + + else: + + message = await ctx.send(error_function()) + + # Let the user read the message for 2.5 seconds + await asyncio.sleep(2.5) + # Delete the message + await message.delete() + except FileNotFoundError as e: + print(e) + # Bot ~8Ball command @commands.command(aliases=['8ball', '8Ball']) @cooldown(1, 0.5, BucketType.channel) @@ -195,16 +229,6 @@ class Fun(commands.Cog): except FileNotFoundError as e: print(e) - @commands.Cog.listener() - async def on_command_error(self, ctx, target: discord.member): - if isinstance(target, commands.MissingRequiredArgument): - message = await ctx.send("Uh oh! Couldn't find anyone to mention! Try again!") - - # Let the user read the message for 2.5 seconds - await asyncio.sleep(1.5) - # Delete the message - await message.delete() - def error_function(): return "Sorry! I only work in #bot-commands!"