[Downloader] Add command to list pinned cogs (#3974)

This commit is contained in:
aikaterna 2020-06-18 06:43:59 -07:00 committed by GitHub
parent 9594284f6c
commit 35365a7154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -861,6 +861,31 @@ class Downloader(commands.Cog):
message += _("\nThese cogs weren't pinned: ") + humanize_list(not_pinned)
await self.send_pagified(ctx, message)
@cog.command(name="listpinned")
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)
if pinned_list:
message = humanize_list(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:]
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:
page = _("Pinned Cogs: \n") + page
await ctx.send(box(page))
@cog.command(name="checkforupdates")
async def _cog_checkforupdates(self, ctx: commands.Context) -> None:
"""