From 4e9aa1ec0a4ee3a8c281d78d766c78796a741863 Mon Sep 17 00:00:00 2001 From: Rohan Reddy Alleti Date: Thu, 18 Aug 2022 21:41:47 +0530 Subject: Help command fix, normalize suggestions for unknown commands (#1064) Co-authored-by: Xithrius <15021300+Xithrius@users.noreply.github.com> --- bot/utils/commands.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 bot/utils/commands.py (limited to 'bot/utils/commands.py') 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] -- cgit v1.2.3