[V3 Core] Moved [p]cogs command to CogManager (#1076)

* Move cogs command to CogManager

* Move cogs command to CogManager

* self.bot -> ctx.bot

* Typing

* Missing import
This commit is contained in:
aikaterna 2017-11-05 10:05:29 -08:00 committed by Will
parent 2c6af90703
commit ef6dbee516
2 changed files with 24 additions and 23 deletions

View File

@ -185,28 +185,6 @@ class Downloader:
elif target.is_file(): elif target.is_file():
os.remove(str(target)) os.remove(str(target))
@commands.command()
@checks.is_owner()
async def cogs(self, ctx):
"""
Lists all loaded and available cogs.
"""
loaded = set(self.bot.extensions.keys())
all = set(await self.bot.cog_mgr.available_modules())
unloaded = all - loaded
msg = ("+ Loaded\n"
"{}\n\n"
"- Unloaded\n"
"{}"
"".format(", ".join(sorted(loaded)),
", ".join(sorted(unloaded)))
)
for page in pagify(msg, [" "], shorten_by=18):
await ctx.send(box(page.lstrip(" "), lang="diff"))
@commands.group() @commands.group()
@checks.is_owner() @checks.is_owner()

View File

@ -13,7 +13,7 @@ from .i18n import CogI18n
from .data_manager import cog_data_path from .data_manager import cog_data_path
from discord.ext import commands from discord.ext import commands
from .utils.chat_formatting import box from .utils.chat_formatting import box, pagify
__all__ = ["CogManager"] __all__ = ["CogManager"]
@ -397,3 +397,26 @@ class CogManagerUI:
install_path = await ctx.bot.cog_mgr.install_path() install_path = await ctx.bot.cog_mgr.install_path()
await ctx.send(_("The bot will install new cogs to the `{}`" await ctx.send(_("The bot will install new cogs to the `{}`"
" directory.").format(install_path)) " directory.").format(install_path))
@commands.command()
@checks.is_owner()
async def cogs(self, ctx: commands.Context):
"""
Lists all loaded and available cogs.
"""
loaded = set(ctx.bot.extensions.keys())
all = set(await ctx.bot.cog_mgr.available_modules())
unloaded = all - loaded
msg = ("+ Loaded\n"
"{}\n\n"
"- Unloaded\n"
"{}"
"".format(", ".join(sorted(loaded)),
", ".join(sorted(unloaded)))
)
for page in pagify(msg, [" "], shorten_by=18):
await ctx.send(box(page.lstrip(" "), lang="diff"))