From dbb8506e8bb221cc06ad130468e3af928a0e25e2 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 22 Jun 2020 22:07:33 +0100 Subject: [PATCH] Refactored some code --- cogs/WaifuImages.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/cogs/WaifuImages.py b/cogs/WaifuImages.py index 194bb9f7..0211da27 100644 --- a/cogs/WaifuImages.py +++ b/cogs/WaifuImages.py @@ -176,6 +176,22 @@ class Waifus(commands.Cog): 'izzy', 'david', 'clarity', 'angel', 'chloe', 'corona', 'skye'] + def displayServerImage(array, ctx, name): + # If the channel that the command has been sent is in the list of accepted channels + if str(ctx.channel) in settings.channels: + # Set member as the author + member = ctx.message.author + userAvatar = member.avatar_url + + embed = discord.Embed( + title=f"**Look At What A Cutie {name.capitalize()} is!! **", + colour=discord.Colour(random.choice(settings.colour_list))) + embed.set_image(url=random.choice(array)) + embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) + embed.timestamp = datetime.datetime.utcnow() + + return embed + if name: proper_name = name.lower() try: @@ -212,22 +228,5 @@ class Waifus(commands.Cog): await ctx.send(embed=embed) -def displayServerImage(array, ctx, name): - # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in settings.channels: - # Set member as the author - member = ctx.message.author - userAvatar = member.avatar_url - - embed = discord.Embed( - title=f"**Look At What A Cutie {name.capitalize()} is!! **", - colour=discord.Colour(random.choice(settings.colour_list))) - embed.set_image(url=random.choice(array)) - embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) - embed.timestamp = datetime.datetime.utcnow() - - return embed - - def setup(bot): bot.add_cog(Waifus(bot))