From 00fb93d50a75711528493d4e308edf16145ce1b5 Mon Sep 17 00:00:00 2001 From: JustMaffie Date: Sun, 28 May 2017 17:51:55 -0700 Subject: [PATCH] Fix Emoji parser --- webapp/titanembeds/EmojiParser.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webapp/titanembeds/EmojiParser.py b/webapp/titanembeds/EmojiParser.py index 70d6ffb..45d369e 100644 --- a/webapp/titanembeds/EmojiParser.py +++ b/webapp/titanembeds/EmojiParser.py @@ -5,13 +5,15 @@ def parseEmoji(textToParse, guild_id): _endpoint = "/guilds/{guild_id}".format(guild_id=guild_id) _method = "GET" response = discord_api.request(_method, _endpoint) + if 'code' not in response['content']: + return textToParse emojis = [] - emojis = re.findall(":(.*?):", textToParse) + emojis = re.findall("<:(.*?):(.*)?>", textToParse) newText = textToParse - for emoji in response['emojis']: + for emoji in response['content']['emojis']: name = emoji['name'] emojiId = emoji['id'] for emoji2 in emojis: if name.lower is emoji2.replace(":", "").lower(): - newText = newText.replace(":{}:".format(name), "".format(id)) - return newText \ No newline at end of file + newText = newText.replace("<:{}}:{}>".format(name, emojiId), "".format(emojiId)) + return newText