fix: finally got icon urls for unicode emojis working I think

This commit is contained in:
Seaswimmer 2023-08-08 19:52:10 -04:00
parent bf81e7278a
commit d2ea4eaa31
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -14,6 +14,9 @@ from redbot.core.utils.common_filters import (
escape_spoilers_and_mass_mentions
)
import aiohttp
import wand.color
import wand.image
from wand.api import library
_ = T_ = Translator("General", __file__)
@ -495,17 +498,13 @@ class Info(commands.Cog):
await ctx.send(embed=data)
async def fetch_twemoji_url(self, unicode_emoji):
async def fetch_twemoj(self, unicode_emoji):
base_url = "https://cdn.jsdelivr.net/gh/jdecked/twemoji@latest/assets/72x72/"
emoji_codepoint = "-".join([hex(ord(char))[2:] for char in unicode_emoji])
emoji_url = f"{base_url}{emoji_codepoint}.png"
async with aiohttp.ClientSession() as session:
async with session.get(emoji_url) as response:
if response.status == 200:
return emoji_url.src
else:
return None
segments = emoji_codepoint.split("-")
valid_segments = [seg for seg in segments if len(seg) >= 4]
emoji_url = f"{base_url}{valid_segments[0]}.png"
return emoji_url
@commands.command()
@commands.guild_only()