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()

Co-authored-by: Jakub Kuczys <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Kreusada 2022-06-05 18:27:36 +01:00 committed by GitHub
parent 5522f909bd
commit 9c11e85bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1057,26 +1057,26 @@ 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(
f"({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: