From f818205ad2165628b3bc2cde7679a43d8e6531c2 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 5 Nov 2020 00:58:39 +0100 Subject: [PATCH] Add help and make list command --- extensions/extension.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/extensions/extension.py b/extensions/extension.py index b113e9f..42be296 100644 --- a/extensions/extension.py +++ b/extensions/extension.py @@ -20,13 +20,25 @@ class Extension(commands.Cog): @commands.is_owner() async def extension(self, ctx: commands.Context): if ctx.invoked_subcommand is None: - embed = Embed(title="Extensions") - for extension in self.bot.extensions: - embed.add_field(name=extension, value="Loaded", inline=False) - await ctx.send(embed=embed) + await ctx.invoke(self.extension_help) + + @extension.group("help", pass_context=True) + async def extension_help(self, ctx: commands.Context): + embed = Embed(title="Extension help") + embed.add_field(name="extension list", value="List all loaded extensions", inline=False) + embed.add_field(name="extension load ", value="Load an extension", inline=False) + embed.add_field(name="extension unload ", value="Unload an extension", inline=False) + embed.add_field(name="extension reload ", value="Reload an extension", inline=False) + await ctx.send(embed=embed) + + @extension.group("list", pass_context=True) + async def extension_list(self, ctx: commands.Context): + embed = Embed(title="Extensions list") + for extension in self.bot.extensions: + embed.add_field(name=extension, value="Loaded", inline=False) + await ctx.send(embed=embed) @extension.group("load", pass_context=True) - @commands.is_owner() async def extension_load(self, ctx: commands.Context, name: str): try: self.bot.load_extension(name) @@ -37,7 +49,6 @@ class Extension(commands.Cog): await ctx.message.add_reaction("\U0001f44d") @extension.group("unload", pass_context=True) - @commands.is_owner() async def extension_unload(self, ctx: commands.Context, name: str): try: self.bot.unload_extension(name) @@ -48,7 +59,6 @@ class Extension(commands.Cog): await ctx.message.add_reaction("\U0001f44d") @extension.group("reload", pass_context=True) - @commands.is_owner() async def extension_reload(self, ctx: commands.Context, name: str): try: self.bot.unload_extension(name)