diff --git a/emojiinfo/emojiinfo.py b/emojiinfo/emojiinfo.py index e6abbaa..769e093 100644 --- a/emojiinfo/emojiinfo.py +++ b/emojiinfo/emojiinfo.py @@ -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,10 +42,11 @@ 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: - if response.status != 200: - return None - image = await response.read() + async with aiohttp.ClientSession() as session: + async with session.get(emoji_url) as response: + if response.status != 200: + return None + image = await response.read() dominant_color = ColorThief(io.BytesIO(image)).get_color(quality=1) color = discord.Color.from_rgb(*dominant_color) return color @@ -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)