aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/commands.py
blob: 7c04a25acfbf951ed94b88a40fd6a038f28b1415 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
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]