From e9a9b22d0febcf47fd95cc441123e64a55c11721 Mon Sep 17 00:00:00 2001 From: Red-GitHubBot <88117545+Red-GitHubBot@users.noreply.github.com> Date: Sun, 5 Jun 2022 19:38:55 +0200 Subject: [PATCH] [3.4] Include commit hash for each cog inside `[p]cog listpinned` (#5563) (#5761) * [3.4] Include commit hash for each cog inside `[p]cog listpinned` (#5563) * Initial commit * Necessary amendments/changes * style changes (i knew id have to do this...) * Use inline() (cherry picked from commit 9c11e85bb44873da18db2144955301124566ef4b) Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com> Co-authored-by: Jakub Kuczys <6032823+jack1142@users.noreply.github.com> * Don't use _() inside f-strings in 3.4 as it uses older redgettext * style Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com> Co-authored-by: Jakub Kuczys <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 5a81f115d..bd5649fec 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1056,26 +1056,27 @@ class Downloader(commands.Cog): async def _cog_listpinned(self, ctx: commands.Context): """List currently pinned cogs.""" installed = await self.installed_cogs() - pinned_list = sorted([cog.name for cog in installed if cog.pinned], key=str.lower) + pinned_list = sorted( + [cog for cog in installed if cog.pinned], key=lambda cog: cog.name.lower() + ) if pinned_list: - message = humanize_list(pinned_list) + message = "\n".join( + "({}) {}".format(inline(cog.commit[:7] or _("unknown")), cog.name) + for cog in pinned_list + ) else: message = _("None.") if await ctx.embed_requested(): embed = discord.Embed(color=(await ctx.embed_colour())) - for page in pagify(message, delims=[", "], page_length=900): - name = _("(continued)") if page.startswith(", ") else _("Pinned Cogs:") - if page.startswith(", "): - page = page[2:] + for page in pagify(message, page_length=900): + name = _("(continued)") if page.startswith("\n") else _("Pinned Cogs:") embed.add_field(name=name, value=page, inline=False) await ctx.send(embed=embed) else: - for page in pagify(message, delims=[", "], page_length=1900): - if page.startswith(", "): - page = page[2:] - else: + for page in pagify(message, page_length=1900): + if not page.startswith("\n"): page = _("Pinned Cogs: \n") + page - await ctx.send(box(page)) + await ctx.send(page) @cog.command(name="checkforupdates") async def _cog_checkforupdates(self, ctx: commands.Context) -> None: