Skip to content

Commit

Permalink
better not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
greeeen-dev committed Nov 21, 2024
1 parent 9f82fdc commit d8ac7cd
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion bridge_revolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,16 @@ async def help(self, ctx, *, query: Optional[str] = None):
any(search_query.lower() in alias.lower() for alias in command.aliases)
)
]

for command in commands:
try:
canrun = await ctx.can_run(command=command)
except:
canrun = False

if not canrun:
commands.remove(command)

embed.title += ' / search'
embed.description = (
f'Searching: {search_query} (**{len(commands)}** results)\n{embed.description}\n'+
Expand All @@ -1537,14 +1547,26 @@ async def help(self, ctx, *, query: Optional[str] = None):
f'Use `{self.bot.command_prefix}help page:<number>` to navigate through pages.'
)
commands = self.get_all_commands()

for command in commands:
try:
canrun = await ctx.can_run(command=command)
except:
canrun = False

if not canrun:
commands.remove(command)

if query and not page:
found = False
try:
try:
command_focus = self.get_command(query)
except KeyError:
command_focus = self.get_command(query.lower())
if type(command_focus) is rv_commands.Group:
raise KeyError()
found = True
except KeyError:
try:
if type(command_focus) is rv_commands.Group:
Expand All @@ -1557,10 +1579,19 @@ async def help(self, ctx, *, query: Optional[str] = None):
if not type(group) is rv_commands.Group:
raise KeyError()
command_focus = group.get_command(query.split(' ')[1])
found = True
else:
raise KeyError()
except KeyError:
return await ctx.send('Invalid command. Use `search:command` to look up commands.')
pass

try:
canrun = await ctx.can_run(command=command_focus)
except:
canrun = False

if not canrun or not found:
await ctx.send('Invalid command. Use `search:command` to look up commands.')

if command_focus:
cmdname = (
Expand Down

0 comments on commit d8ac7cd

Please sign in to comment.