From b7d1e22fa4be3e44ca3ae47530cacec2ec2c67ff Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Tue, 1 Sep 2020 19:30:20 -0700 Subject: [PATCH] adding meme. fixes #19 --- app/bot.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/app/bot.py b/app/bot.py index 431b6aba..66c8ec01 100755 --- a/app/bot.py +++ b/app/bot.py @@ -132,13 +132,14 @@ async def emoji(ctx): import core_utils emoji_staging = '/tmp/emoji' - await ctx.send("emoji successfully uploaded! Heres how it looks in a sentence {}\nUse it with `:{}:`".format( - await ctx.message.guild.create_custom_emoji( - name=emoji_name, - image=open(core_utils.download_image(url, emoji_staging), "rb").read() - ), emoji_name + try: + await ctx.send("emoji successfully uploaded! Heres how it looks in a sentence {}\nUse it with `:{}:`".format( + await ctx.message.guild.create_custom_emoji( + name=emoji_name, + image=open(core_utils.download_image(url, emoji_staging), "rb").read() + ), emoji_name + ) ) - ) except Exception: await ctx.send( "I wasnt able to upload that image as an emoji. Sorry" @@ -155,14 +156,28 @@ async def avatar(ctx): # Code stolen from this reddit post # https://www.reddit.com/r/discordapp/comments/74bb4z/retrieve_a_mentioned_users_avatar_using_discordpy for user in profile: + avatar_url = str(user.avatar_url).replace('.webp', '.png') await ctx.send( embed=generate_embed( embed_title="{}#{}".format(user.name, user.discriminator), - embed_url=str(user.avatar_url).replace('.webp', '.png'), - embed_description="[Direct Link]({})".format(str(user.avatar_url).replace('.webp', '.png')) + embed_url=avatar_url, + embed_description="[Direct Link]({})".format(avatar_url) ) ) +@bot.command(name='meme') +async def meme(ctx): + + import meme_gen + await ctx.message.delete() + await ctx.send( + embed=generate_embed( + embed_url=meme_gen.parse_message( + ctx.message.content + ) + ) + ) + @bot.command(name='redpanda') async def redpanda(ctx):