diff options
author | stolenvw <stolenvw@hotmail.com> | 2021-04-14 18:19:48 -0400 |
---|---|---|
committer | stolenvw <stolenvw@hotmail.com> | 2021-04-14 18:19:48 -0400 |
commit | 65d2ac46fa21b25d597b53089477d20c6b703a06 (patch) | |
tree | ccbbc5c0dd06cbd1934a8de04ba318d7865a74b8 /code | |
parent | bb01f1a0ca617be1ea4ef64219e032cf946163e7 (diff) |
Fixed help command where it would error if you did not have permisson to a command.
Diffstat (limited to 'code')
-rw-r--r-- | code/botcmds/helpcmds.py | 9 |
1 files 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) |