[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 9c11e85bb4)

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>
This commit is contained in:
Red-GitHubBot
2022-06-05 19:38:55 +02:00
committed by GitHub
parent f9b6f05415
commit e9a9b22d0f

View File

@@ -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: