sir-lancebot icon indicating copy to clipboard operation
sir-lancebot copied to clipboard

Help command fix, normalize suggestions for unknown commands

Open RohanJnr opened this issue 3 years ago • 1 comments

Relevant Issues

issue: #863

Refer to https://github.com/python-discord/sir-lancebot/pull/884

Fixes

  • The help command used to raise an error when provided with an invalid command name (fixed)
  • There used to be different command suggestions from the help command and the error handler when an unknown command was provided.
    • This has been fixed by using the same method for finding similar commands.

Changes

  • Providing an invalid subcommand but valid parent command (for example: !ext listt, ext is valid but subcommand listt is invalid) now sends the help command output for the parent command.

  • Using bot.all_commands attribute instead of bot.walk_commands() generator.

    • walk_commands() is not useful in the error_handler because (as it provides us with all subcommands also), when there is an invalid subcommand, the parent command (commands.Group) handles this case and sends a help message, hence, never reaching the error_handler.
    • all_commands does not give us subcommands (it gives aliases which is pretty useful).
  • Using rapidfuzz for finding similar commands instead of difflib (reasons being speed).

  • Error handler now sends multiple command suggestions instead of 1 when user is trying to run an unknown command.

Yet to decide/to discuss

The help command lists/suggests commands that may not in the user's power to invoke them. Should we filter commands when listing them such that to only show them the commands which they can invoke ?

This is the current output when user invokes help command on a restricted command. Uploading image.png…

Did you:

RohanJnr avatar Jun 21 '22 20:06 RohanJnr

I'm in the middle of a review (sorry for taking so long!) but I ran out of time to finish it today :/ I'll submit my review tomorrow.

ichard26 avatar Jul 10 '22 02:07 ichard26