diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index be3854e57..d064c1394 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -947,7 +947,7 @@ class Downloader(commands.Cog): "\nIt was most likely removed without using `{prefix}cog uninstall`.\n" "You may need to remove those files manually if the cog is still usable." " If so, ensure the cog has been unloaded with {command}." - ).format(command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}")) + ).format(command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}") ) await self.send_pagified(ctx, message) @@ -1269,48 +1269,47 @@ class Downloader(commands.Cog): - `` The repo to list cogs from. """ - available_cogs = 0 - installed = await self.installed_cogs() + all_installed_cogs = await self.installed_cogs() + installed_cogs_in_repo = [ + cog + for cog in all_installed_cogs + if cog.repo_name == repo.name + ] installed_str = "\n".join( - [ - "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") - for i in installed - if i.repo_name == repo.name - ] + "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") + for i in installed_cogs_in_repo ) + if not installed_str: installed_str = _("No cogs installed.") - elif len(installed) > 1: + elif len(installed_cogs_in_repo) > 1: installed_str = ( - _("Installed Cogs: ({installed_number})\n").format(installed_number=len(installed)) - + installed_str + _("Installed Cogs:\n{text}").format(text=installed_str) ) else: installed_str = ( - _("Installed Cog: ({installed_number})\n").format(installed_number=len(installed)) - + installed_str + _("Installed Cog:\n{text}").format(text=installed_str) ) available_str = "\n".join( - [ - "+ {}: {}".format(cog.name, cog.short or "") - for cog in repo.available_cogs - if not (cog.hidden or cog in installed) - ] + "+ {}{}".format(cog.name, ": {}".format(cog.short) if cog.short else "") + for cog in repo.available_cogs + if not (cog.hidden or cog in installed_cogs_in_repo) ) - for cog in repo.available_cogs: - if not (cog.hidden or cog in installed): - available_cogs += 1 + + + available_cogs = sum( + not cog.hidden and cog not in installed_cogs_in_repo for cog in repo.available_cogs + ) + if not available_str: cogs = _("No cogs available.") elif available_cogs > 1: cogs = ( - _("Available Cogs: ({available_number})\n").format(available_number=available_cogs) - + available_str + _("Available Cogs:\n{text}").format(text=available_str) ) else: cogs = ( - _("Available Cog: ({available_number})\n").format(available_number=available_cogs) - + available_str + _("Available Cog:\n{text}").format(text=available_str) ) cogs = cogs + "\n\n" + installed_str for page in pagify(cogs, ["\n"], shorten_by=16):