feat: added support for unicode emojis (maybe)
This commit is contained in:
parent
417c4830a3
commit
6d92eb74c4
1 changed files with 15 additions and 3 deletions
18
info/info.py
18
info/info.py
|
@ -13,7 +13,7 @@ from redbot.core.utils.common_filters import (
|
||||||
filter_invites,
|
filter_invites,
|
||||||
escape_spoilers_and_mass_mentions
|
escape_spoilers_and_mass_mentions
|
||||||
)
|
)
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
_ = T_ = Translator("General", __file__)
|
_ = T_ = Translator("General", __file__)
|
||||||
|
|
||||||
|
@ -495,6 +495,18 @@ class Info(commands.Cog):
|
||||||
|
|
||||||
await ctx.send(embed=data)
|
await ctx.send(embed=data)
|
||||||
|
|
||||||
|
async def fetch_twemoji_url(self, unicode_emoji):
|
||||||
|
base_url = "https://twemoji.maxcdn.com/v/latest/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
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def roleinfo(self, ctx, role: discord.Role, list_permissions: bool = False):
|
async def roleinfo(self, ctx, role: discord.Role, list_permissions: bool = False):
|
||||||
|
@ -503,8 +515,8 @@ class Info(commands.Cog):
|
||||||
icon = role.display_icon
|
icon = role.display_icon
|
||||||
if isinstance(icon, discord.Asset):
|
if isinstance(icon, discord.Asset):
|
||||||
icon_url = icon.url
|
icon_url = icon.url
|
||||||
else:
|
elif isinstance(icon, str):
|
||||||
icon_url = None
|
icon_url = await self.fetch_twemoji_url(unicode_emoji=icon)
|
||||||
permissions = role.permissions
|
permissions = role.permissions
|
||||||
if role.color.value == 0:
|
if role.color.value == 0:
|
||||||
colorint = 10070709
|
colorint = 10070709
|
||||||
|
|
Loading…
Reference in a new issue