From 65d2ac46fa21b25d597b53089477d20c6b703a06 Mon Sep 17 00:00:00 2001 From: stolenvw Date: Wed, 14 Apr 2021 18:19:48 -0400 Subject: Fixed help command where it would error if you did not have permisson to a command. --- code/botcmds/helpcmds.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/botcmds/helpcmds.py b/code/botcmds/helpcmds.py index 1cf3157..ea5572e 100644 --- a/code/botcmds/helpcmds.py +++ b/code/botcmds/helpcmds.py @@ -52,6 +52,11 @@ class Help(commands.Cog): # checks if cog parameter was given # if not: sending all modules and commands not associated with a cog + async def predicate(cmd): + try: + return await cmd.can_run(ctx) + except commands.CommandError: + return False if not input: # starting to build embed emb = discord.Embed(title='Valheim Plus Discord Bot', url="https://github.com/stolenvw/ValheimPlus-Discord_Bot", color=discord.Color.blue(), @@ -64,7 +69,7 @@ class Help(commands.Cog): valid = False for command in self.bot.get_cog(cog).get_commands(): if not command.hidden: - valid = await command.can_run(ctx) + valid = await predicate(command) if valid: break if valid: @@ -104,7 +109,7 @@ class Help(commands.Cog): for command in self.bot.get_cog(cog).get_commands(): # if cog is not hidden if not command.hidden: - valid = await command.can_run(ctx) + valid = await predicate(command) if valid: if not command.usage: emb.add_field(name=f"`{prefix}{command.name}`", value=command.help, inline=False) -- cgit v1.2.3