Titan/webapp/titanembeds/EmojiParser.py
JustMaffie 187ae6809f Create EmojiParser.py
Update EmojiParser.py

Update EmojiParser.py

Now parsing custom emoji

Now parsing custom emoji
2017-05-28 16:06:02 -07:00

17 lines
638 B
Python

from titanembeds.utils import discord_api
import re
def parseEmoji(textToParse, guild_id):
_endpoint = "/guilds/{guild_id}".format(guild_id=guild_id)
_method = "GET"
response = discord_api.request(_method, _endpoint)
emojis = []
emojis = re.findall(":(.*?):", textToParse)
newText = textToParse
for emoji in response['emojis']:
name = emoji['name']
emojiId = emoji['id']
for emoji2 in emojis:
if name.lower is emoji2.replace(":", "").lower():
newText = newText.replace(":{}:".format(name), "<img src='https://cdn.discordapp.com/emojis/{}.png'></img>".format(id))
return newText