diff options
| -rw-r--r-- | bot/exts/evergreen/emoji_count.py | 25 | 
1 files changed, 13 insertions, 12 deletions
diff --git a/bot/exts/evergreen/emoji_count.py b/bot/exts/evergreen/emoji_count.py index 95e4c927..ecdb12fa 100644 --- a/bot/exts/evergreen/emoji_count.py +++ b/bot/exts/evergreen/emoji_count.py @@ -6,7 +6,7 @@ from typing import Dict, Optional  import discord  from discord.ext import commands -from bot.constants import Colours +from bot.constants import Colours, ERROR_REPLIES  log = logging.getLogger(__name__) @@ -25,7 +25,6 @@ class EmojiCount(commands.Cog):          embed.timestamp = datetime.datetime.utcnow()          if len(emoji) == 1:              for key, value in emoji.items(): -                print(key)                  embed.description = f"There are **{len(value)}** emojis in the **{key}** category"                  embed.set_thumbnail(url=random.choice(value).url)          else: @@ -35,7 +34,7 @@ class EmojiCount(commands.Cog):                  emoji_info = f'There are **{len(value)}** emojis in the **{key}** category\n'                  msg += f'<:{emoji_choice.name}:{emoji_choice.id}> {emoji_info}'              embed.description = msg -        log.trace('Emoji embed sent') +        log.trace('Emoji embed built')          return embed      @staticmethod @@ -43,23 +42,25 @@ class EmojiCount(commands.Cog):          """Genrates error embed."""          embed = discord.Embed()          embed.color = Colours.soft_red -        embed.title = "Invalid Input" +        embed.title = random.choice(ERROR_REPLIES)          emoji_dict = {}          for emoji in ctx.guild.emojis:              emoji_dict.update({emoji.name.split("_")[0]: []})          error_comp = ', '.join(key for key in emoji_dict.keys())          embed.description = f"These are the valid categories\n```{error_comp}```" -        log.trace("Error embed sent") +        log.trace("Error embed built")          return embed -    def emoji_list(self, ctx: commands.Context, emojis: dict) -> Dict: -        """Genrates dictionary of emojis given by the user.""" +    def emoji_list(self, ctx, categories) -> Dict: +        """Generates an embed with the emoji names and count.""" +        out = {category: [] for category in categories} +          for emoji in ctx.guild.emojis: -            for key, value in emojis.items(): -                if emoji.name.split("_")[0] == key: -                    value.append(emoji) -        log.trace("Emoji dict sent") -        return emojis +            category = emoji.name.split('_')[0] +            if category in out: +                out[category].append(emoji) +        log.trace("Emoji dict built") +        return out      @commands.command(name="emoji_count", aliases=["ec"])      async def ec(self, ctx: commands.Context, *, emoji: str = None) -> Optional[str]:  |