fix: finally got icon urls for unicode emojis working I think
This commit is contained in:
parent
bf81e7278a
commit
d2ea4eaa31
1 changed files with 8 additions and 9 deletions
17
info/info.py
17
info/info.py
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue