fix(emojiinfo): use aiohttp.ClientSession
This commit is contained in:
parent
7ae8226ca5
commit
80dcfea95e
1 changed files with 7 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
import io
|
||||
from typing import Any, Literal
|
||||
|
||||
import aiohttp
|
||||
import discord
|
||||
from colorthief import ColorThief
|
||||
from red_commons.logging import RedTraceLogger, getLogger
|
||||
|
@ -41,7 +42,8 @@ class EmojiInfo(commands.Cog):
|
|||
return emoji_url
|
||||
|
||||
async def fetch_primary_color(self, emoji_url: str) -> discord.Color | None:
|
||||
async with self.bot.http_session.get(emoji_url) as response:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(emoji_url) as response:
|
||||
if response.status != 200:
|
||||
return None
|
||||
image = await response.read()
|
||||
|
@ -52,6 +54,7 @@ class EmojiInfo(commands.Cog):
|
|||
@commands.hybrid_command(name="emoji")
|
||||
async def emoji(self, ctx: commands.Context, emoji: str, ephemeral: bool = False) -> None:
|
||||
"""Retrieve information about an emoji."""
|
||||
await ctx.defer(ephemeral=ephemeral)
|
||||
emoji: discord.PartialEmoji = discord.PartialEmoji.from_str(value=emoji)
|
||||
if emoji.is_unicode_emoji():
|
||||
emoji_url = await self.fetch_twemoji(unicode_emoji=emoji.name)
|
||||
|
|
Loading…
Reference in a new issue