2017-05-28 22:43:50 +02:00
|
|
|
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)
|
2017-05-29 02:51:55 +02:00
|
|
|
if 'code' not in response['content']:
|
|
|
|
return textToParse
|
2017-05-28 22:43:50 +02:00
|
|
|
emojis = []
|
2017-05-29 02:51:55 +02:00
|
|
|
emojis = re.findall("<:(.*?):(.*)?>", textToParse)
|
2017-05-28 22:43:50 +02:00
|
|
|
newText = textToParse
|
2017-05-29 02:51:55 +02:00
|
|
|
for emoji in response['content']['emojis']:
|
2017-05-28 22:43:50 +02:00
|
|
|
name = emoji['name']
|
|
|
|
emojiId = emoji['id']
|
|
|
|
for emoji2 in emojis:
|
|
|
|
if name.lower is emoji2.replace(":", "").lower():
|
2017-05-29 02:51:55 +02:00
|
|
|
newText = newText.replace("<:{}}:{}>".format(name, emojiId), "<img src='https://cdn.discordapp.com/emojis/{}.png'></img>".format(emojiId))
|
|
|
|
return newText
|