mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
20 lines
733 B
Python
20 lines
733 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)
|
|
if not response.get("success", False):
|
|
return textToParse
|
|
emojis = []
|
|
emojis = re.findall("<:(.*?):(.*)?>", textToParse)
|
|
newText = textToParse
|
|
for emoji in response['content']['emojis']:
|
|
name = emoji['name']
|
|
emojiId = emoji['id']
|
|
for emoji2 in emojis:
|
|
if name.lower() == emoji2[0].lower():
|
|
newText = newText.replace("<:{}:{}>".format(name, emojiId), "<img src='https://cdn.discordapp.com/emojis/{}.png'></img>".format(emojiId))
|
|
return newText
|