diff options
| -rw-r--r-- | bot/cogs/help.py | 37 | ||||
| -rw-r--r-- | bot/cogs/moderation/infractions.py | 1 | ||||
| -rw-r--r-- | bot/cogs/moderation/management.py | 1 | 
3 files changed, 31 insertions, 8 deletions
| diff --git a/bot/cogs/help.py b/bot/cogs/help.py index 37d12b2d5..0847e5e17 100644 --- a/bot/cogs/help.py +++ b/bot/cogs/help.py @@ -1,5 +1,4 @@  import asyncio -import inspect  import itertools  from collections import namedtuple  from contextlib import suppress @@ -107,12 +106,26 @@ class HelpSession:          if command:              return command -        cog = self._bot.cogs.get(query) -        if cog: +        # Find all cog categories that match. +        cogs = self._bot.cogs.values() +        cog_matches = [cog for cog in cogs if hasattr(cog, "category") and cog.category == query] + +        # Try to search by cog name if no categories match. +        if not cog_matches: +            cog = self._bot.cogs.get(query) + +            # Don't consider it a match if the cog has a category. +            if cog and not hasattr(cog, "category"): +                cog_matches = [cog] + +        if cog_matches: +            cog = cog_matches[0] +            cmds = (cog.get_commands() for cog in cog_matches)  # Commands of all cogs +              return Cog( -                name=cog.qualified_name, -                description=inspect.getdoc(cog), -                commands=[c for c in self._bot.commands if c.cog is cog] +                name=cog.category if hasattr(cog, "category") else cog.qualified_name, +                description=cog.description, +                commands=tuple(itertools.chain.from_iterable(cmds))  # Flatten the list              )          self._handle_not_found(query) @@ -207,8 +220,16 @@ class HelpSession:          A zero width space is used as a prefix for results with no cogs to force them last in ordering.          """ -        cog = cmd.cog_name -        return f'**{cog}**' if cog else f'**\u200bNo Category:**' +        if cmd.cog: +            try: +                if cmd.cog.category: +                    return f'**{cmd.cog.category}**' +            except AttributeError: +                pass + +            return f'**{cmd.cog_name}**' +        else: +            return "**\u200bNo Category:**"      def _get_command_params(self, cmd: Command) -> str:          """ diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py index 5a93745ba..b2b03e46c 100644 --- a/bot/cogs/moderation/infractions.py +++ b/bot/cogs/moderation/infractions.py @@ -30,6 +30,7 @@ class Infractions(Scheduler, commands.Cog):      def __init__(self, bot: commands.Bot):          self.bot = bot +        self.category = "Moderation"          self._muted_role = discord.Object(constants.Roles.muted)          super().__init__() diff --git a/bot/cogs/moderation/management.py b/bot/cogs/moderation/management.py index 567c4e2df..c4fd3894e 100644 --- a/bot/cogs/moderation/management.py +++ b/bot/cogs/moderation/management.py @@ -35,6 +35,7 @@ class ModManagement(commands.Cog):      def __init__(self, bot: commands.Bot):          self.bot = bot +        self.category = "Moderation"      @property      def mod_log(self) -> ModLog: | 
