fix(emojiinfo): add the PartialEmoji.from_str call to the try and except blocks

This commit is contained in:
Seaswimmer 2024-05-08 16:02:56 -04:00
parent d126f1e6d3
commit e59503829f
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -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():