mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Fix Emoji parser
This commit is contained in:
parent
bc95c94a7b
commit
00fb93d50a
@ -5,13 +5,15 @@ def parseEmoji(textToParse, guild_id):
|
|||||||
_endpoint = "/guilds/{guild_id}".format(guild_id=guild_id)
|
_endpoint = "/guilds/{guild_id}".format(guild_id=guild_id)
|
||||||
_method = "GET"
|
_method = "GET"
|
||||||
response = discord_api.request(_method, _endpoint)
|
response = discord_api.request(_method, _endpoint)
|
||||||
|
if 'code' not in response['content']:
|
||||||
|
return textToParse
|
||||||
emojis = []
|
emojis = []
|
||||||
emojis = re.findall(":(.*?):", textToParse)
|
emojis = re.findall("<:(.*?):(.*)?>", textToParse)
|
||||||
newText = textToParse
|
newText = textToParse
|
||||||
for emoji in response['emojis']:
|
for emoji in response['content']['emojis']:
|
||||||
name = emoji['name']
|
name = emoji['name']
|
||||||
emojiId = emoji['id']
|
emojiId = emoji['id']
|
||||||
for emoji2 in emojis:
|
for emoji2 in emojis:
|
||||||
if name.lower is emoji2.replace(":", "").lower():
|
if name.lower is emoji2.replace(":", "").lower():
|
||||||
newText = newText.replace(":{}:".format(name), "<img src='https://cdn.discordapp.com/emojis/{}.png'></img>".format(id))
|
newText = newText.replace("<:{}}:{}>".format(name, emojiId), "<img src='https://cdn.discordapp.com/emojis/{}.png'></img>".format(emojiId))
|
||||||
return newText
|
return newText
|
||||||
|
Loading…
Reference in New Issue
Block a user