diff options
author | 2020-08-13 17:14:11 -0700 | |
---|---|---|
committer | 2020-08-14 09:43:40 -0700 | |
commit | e81b8d678b24e1504d88901e824e9c52f2d6afcf (patch) | |
tree | 6a7411eefd8d0aaf47daf0303132b808929466a2 | |
parent | Extensions: group by category in list command (diff) |
Extensions: support nested groupings in list command
-rw-r--r-- | bot/cogs/utils/extensions.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/bot/cogs/utils/extensions.py b/bot/cogs/utils/extensions.py index c713cb519..90558c52a 100644 --- a/bot/cogs/utils/extensions.py +++ b/bot/cogs/utils/extensions.py @@ -169,15 +169,13 @@ class Extensions(commands.Cog): lines = [] categories = self.group_extension_statuses() - for category, extensions in categories.items(): + for category, extensions in sorted(categories.items()): # Treat each category as a single line by concatenating everything. # This ensures the paginator will not cut off a page in the middle of a category. - category = category.replace("_", " ").capitalize() + category = category.replace("_", " ").title() extensions = "\n".join(sorted(extensions)) lines.append(f"**{category}**\n{extensions}\n") - lines.sort() # Sort by category name. - log.debug(f"{ctx.author} requested a list of all cogs. Returning a paginated list.") await LinePaginator.paginate(lines, ctx, embed, scale_to_size=700, empty=False) @@ -193,9 +191,10 @@ class Extensions(commands.Cog): path = ext.split(".") if len(path) > COG_PATH_LEN + 1: - extensions = categories.setdefault(path[COG_PATH_LEN], []) + category = " - ".join(path[COG_PATH_LEN:-1]) + extensions = categories.setdefault(category, []) else: - extensions = categories.setdefault("Uncategorised", []) + extensions = categories.setdefault("uncategorised", []) extensions.append(f"{status} {path[-1]}") |