From 8ada699bc41441a91eebbecd60227a56e4ab0412 Mon Sep 17 00:00:00 2001 From: stolenvw Date: Mon, 12 Apr 2021 16:53:11 -0400 Subject: Updated to not show Owner commands to non-owners --- code/botcmds/helpcmds.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/code/botcmds/helpcmds.py b/code/botcmds/helpcmds.py index 10bc239..1cf3157 100644 --- a/code/botcmds/helpcmds.py +++ b/code/botcmds/helpcmds.py @@ -48,7 +48,7 @@ class Help(commands.Cog): # !SET THOSE VARIABLES TO MAKE THE COG FUNCTIONAL! prefix = config.BOT_PREFIX - version = "v1.0.0" + version = "v0.2.0" # checks if cog parameter was given # if not: sending all modules and commands not associated with a cog @@ -61,7 +61,13 @@ class Help(commands.Cog): # iterating trough cogs, gathering descriptions cogs_desc = '' for cog in self.bot.cogs: - if cog != "BotSQL" and cog != "Admin": + valid = False + for command in self.bot.get_cog(cog).get_commands(): + if not command.hidden: + valid = await command.can_run(ctx) + if valid: + break + if valid: cogs_desc += f'`{cog}` {self.bot.cogs[cog].__doc__}\n' # adding 'list' of cogs to embed @@ -98,10 +104,12 @@ class Help(commands.Cog): for command in self.bot.get_cog(cog).get_commands(): # if cog is not hidden if not command.hidden: - if not command.usage: - emb.add_field(name=f"`{prefix}{command.name}`", value=command.help, inline=False) - else: - emb.add_field(name=f"`{prefix}{command.name} {command.usage}`", value=command.help, inline=False) + valid = await command.can_run(ctx) + if valid: + if not command.usage: + emb.add_field(name=f"`{prefix}{command.name}`", value=command.help, inline=False) + else: + emb.add_field(name=f"`{prefix}{command.name} {command.usage}`", value=command.help, inline=False) # found cog - breaking loop break -- cgit v1.2.3-70-g09d2