fix(emojiinfo): seperated the slash command from the normal command
This commit is contained in:
parent
8f6afe754d
commit
ce53908938
1 changed files with 41 additions and 18 deletions
|
@ -53,23 +53,12 @@ class EmojiInfo(commands.Cog):
|
|||
color = discord.Color.from_rgb(*dominant_color)
|
||||
return color
|
||||
|
||||
@commands.hybrid_command(name="emoji")
|
||||
@app_commands.describe(
|
||||
emoji="What emoji would you like to get information on?",
|
||||
ephemeral="Would you like the response to be hidden?"
|
||||
)
|
||||
async def emoji(self, ctx: commands.Context, emoji: str, ephemeral: bool = False) -> None:
|
||||
"""Retrieve information about an emoji."""
|
||||
await ctx.defer(ephemeral=ephemeral)
|
||||
|
||||
emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji)
|
||||
|
||||
async def get_emoji_info(self, emoji: PartialEmoji) -> tuple[str, str]:
|
||||
if emoji.is_unicode_emoji():
|
||||
try:
|
||||
emoji_url = await self.fetch_twemoji(unicode_emoji=emoji.name)
|
||||
except Exception:
|
||||
await ctx.send("Please provide a valid emoji!", ephemeral=ephemeral)
|
||||
return
|
||||
except Exception as e:
|
||||
raise e
|
||||
else:
|
||||
emoji_url = emoji.url
|
||||
|
||||
|
@ -86,7 +75,7 @@ class EmojiInfo(commands.Cog):
|
|||
aliases = f"{bold('Aliases:')} {', '.join(emoji.aliases)}\n" if emoji.aliases else ""
|
||||
group = f"{bold('Group:')} {emoji.group}\n"
|
||||
|
||||
string: str = (
|
||||
return (
|
||||
f"{name}"
|
||||
f"{emoji_id}"
|
||||
f"{bold('Native:')} {emoji.is_unicode_emoji()}\n"
|
||||
|
@ -95,12 +84,46 @@ class EmojiInfo(commands.Cog):
|
|||
f"{bold('Animated:')} {emoji.animated}\n"
|
||||
f"{bold('Markdown:')} {markdown}\n"
|
||||
f"{bold('URL:')} [Click Here]({emoji_url})"
|
||||
)
|
||||
), emoji_url
|
||||
|
||||
@app_commands.command(name="emoji")
|
||||
@app_commands.describe(
|
||||
emoji="What emoji would you like to get information on?",
|
||||
ephemeral="Would you like the response to be hidden?"
|
||||
)
|
||||
async def emoji_slash(self, interaction: discord.Interaction, emoji: str, ephemeral: bool) -> None:
|
||||
"""Retrieve information about an emoji."""
|
||||
interaction.response.defer(ephemeral=ephemeral)
|
||||
|
||||
emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji)
|
||||
|
||||
try:
|
||||
string, emoji_url, = await self.get_emoji_info(emoji)
|
||||
except Exception:
|
||||
return await interaction.followup.send("Please provide a valid emoji!")
|
||||
|
||||
if await self.bot.embed_requested(channel=interaction.channel):
|
||||
embed = embed = discord.Embed(title="Emoji Information", description=string, color = await self.fetch_primary_color(emoji_url) or await self.bot.get_embed_color(interaction.channel))
|
||||
embed.set_thumbnail(url=emoji_url)
|
||||
|
||||
await interaction.followup.send(embed=embed)
|
||||
else:
|
||||
await interaction.followup.send(content=string)
|
||||
|
||||
@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:
|
||||
string, emoji_url, = await self.get_emoji_info(emoji)
|
||||
except Exception:
|
||||
return await ctx.send("Please provide a valid emoji!")
|
||||
|
||||
if await ctx.embed_requested():
|
||||
embed = embed = discord.Embed(title="Emoji Information", description=string, color = await self.fetch_primary_color(emoji_url) or await ctx.embed_color)
|
||||
embed.set_thumbnail(url=emoji_url)
|
||||
|
||||
await ctx.send(embed=embed, ephemeral=ephemeral)
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
await ctx.send(content=string, ephemeral=ephemeral)
|
||||
await ctx.send(content=string)
|
||||
|
|
Loading…
Reference in a new issue