Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it not error out if the emoji isnt from the guild #250

Open
github-actions bot opened this issue Jun 3, 2024 · 0 comments
Open

make it not error out if the emoji isnt from the guild #250

github-actions bot opened this issue Jun 3, 2024 · 0 comments
Labels

Comments

@github-actions
Copy link

github-actions bot commented Jun 3, 2024

# TODO: make it not error out if the emoji isnt from the guild

        await interaction.followup.send(embed=embed)

    # TODO: make it not error out if the emoji isnt from the guild
    @commands.command(
        name="emojiinfo", description="Get information about an emoji. (put emoji as parameter)"
    )
    async def emoji_info(self, ctx: commands.Context[commands.Bot], emoji: discord.Emoji) -> None:
        """
        Get information about an emoji.

        Parameters
        ----------
        ctx : commands.Context[commands.Bot]
            The context object.
        emoji : discord.Emoji
            The emoji to get information about.
        """

        # create custom embed
        embed = discord.Embed(
            title=f"Emoji Info for {emoji.name}",
            color=CONST.EMBED_STATE_COLORS["DEBUG"],
        )

        embed.add_field(name="Name", value=emoji.name, inline=True)
        embed.add_field(name="ID", value=emoji.id, inline=True)
        embed.add_field(name="URL", value=emoji.url, inline=False)
        # set the emoji image as the thumbnail
        embed.set_thumbnail(url=emoji.url)

        # get the emojis usage stats if it exists
        emoji_stats = await self.db_controller.get_emoji_stats(emoji.id)
        if emoji_stats:
            embed.add_field(name="Usage Count", value=emoji_stats.count, inline=True)
            # find how the emoji ranks in the guild
            emoji_stats = await self.db_controller.get_all_emoji_stats()
            emoji_stats = sorted(emoji_stats, key=lambda x: x.count, reverse=True)
            rank = next(
                (
                    index + 1
                    for index, emoji_stat in enumerate(emoji_stats)
                    if emoji_stat.emoji_id == emoji.id
                ),
                None,
            )
            embed.add_field(name="Rank", value=rank, inline=True)

        await ctx.send(embed=embed)

    @commands.Cog.listener()
    async def on_message(self, message: discord.Message) -> None:
        """
@github-actions github-actions bot added the todo label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants