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 escape_spoilers_and_mass_mentions
) )
import aiohttp import aiohttp
import wand.color
import wand.image
from wand.api import library
_ = T_ = Translator("General", __file__) _ = T_ = Translator("General", __file__)
@ -495,17 +498,13 @@ class Info(commands.Cog):
await ctx.send(embed=data) 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/" 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_codepoint = "-".join([hex(ord(char))[2:] for char in unicode_emoji])
emoji_url = f"{base_url}{emoji_codepoint}.png" segments = emoji_codepoint.split("-")
valid_segments = [seg for seg in segments if len(seg) >= 4]
async with aiohttp.ClientSession() as session: emoji_url = f"{base_url}{valid_segments[0]}.png"
async with session.get(emoji_url) as response: return emoji_url
if response.status == 200:
return emoji_url.src
else:
return None
@commands.command() @commands.command()
@commands.guild_only() @commands.guild_only()