diff options
author | 2022-08-18 21:41:47 +0530 | |
---|---|---|
committer | 2022-08-18 16:11:47 +0000 | |
commit | 4e9aa1ec0a4ee3a8c281d78d766c78796a741863 (patch) | |
tree | 14824d34f597fcabc8cedd19e2ff71056123b587 /bot/utils/commands.py | |
parent | Merge pull request #1080 from AbooMinister25/uwu-embed-fix (diff) |
Help command fix, normalize suggestions for unknown commands (#1064)
Co-authored-by: Xithrius <[email protected]>
Diffstat (limited to 'bot/utils/commands.py')
-rw-r--r-- | bot/utils/commands.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bot/utils/commands.py b/bot/utils/commands.py new file mode 100644 index 00000000..7c04a25a --- /dev/null +++ b/bot/utils/commands.py @@ -0,0 +1,11 @@ +from typing import Optional + +from rapidfuzz import process + + +def get_command_suggestions( + all_commands: list[str], query: str, *, cutoff: int = 60, limit: int = 3 +) -> Optional[list]: + """Get similar command names.""" + results = process.extract(query, all_commands, score_cutoff=cutoff, limit=limit) + return [result[0] for result in results] |