Help command fix, normalize suggestions for unknown commands
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 subcommandlisttis invalid) now sends the help command output for the parent command. -
Using
bot.all_commandsattribute instead ofbot.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_commandsdoes not give us subcommands (it gives aliases which is pretty useful).
-
Using
rapidfuzzfor finding similar commands instead ofdifflib(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.
Did you:
- [X] Join the Python Discord Community?
- [X] Read all the comments in this template?
- [X] Ensure there is an issue open, or link relevant discord discussions?
- [X] Read and agree to the contributing guidelines?
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.