From e59503829f11a02fc0c5fe5072992b4f3a63e1a6 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 8 May 2024 16:02:56 -0400 Subject: [PATCH] fix(emojiinfo): add the PartialEmoji.from_str call to the try and except blocks --- emojiinfo/emojiinfo.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/emojiinfo/emojiinfo.py b/emojiinfo/emojiinfo.py index f327eb1..f3a520b 100644 --- a/emojiinfo/emojiinfo.py +++ b/emojiinfo/emojiinfo.py @@ -57,7 +57,7 @@ class EmojiInfo(commands.Cog): if emoji.is_unicode_emoji(): try: emoji_url = await self.fetch_twemoji(unicode_emoji=emoji.name) - except Exception as e: + except IndexError as e: raise e else: emoji_url = emoji.url @@ -95,11 +95,10 @@ class EmojiInfo(commands.Cog): """Retrieve information about an emoji.""" await interaction.response.defer(ephemeral=ephemeral) - emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji) - try: + emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji) string, emoji_url, = await self.get_emoji_info(emoji) - except Exception: + except (IndexError, UnboundLocalError): return await interaction.followup.send("Please provide a valid emoji!") if await self.bot.embed_requested(channel=interaction.channel): @@ -113,11 +112,10 @@ class EmojiInfo(commands.Cog): @commands.command(name="emoji") async def emoji(self, ctx: commands.Context, *, emoji: str) -> None: """Retrieve information about an emoji.""" - emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji) - try: + emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji) string, emoji_url, = await self.get_emoji_info(emoji) - except Exception: + except (IndexError, UnboundLocalError): return await ctx.send("Please provide a valid emoji!") if await ctx.embed_requested():