ErythroGuild / irene

<Erythro>'s server admin bot.
Mozilla Public License 2.0
0 stars 0 forks source link

Sort autocomplete results by edit distance #346

Closed Ernest314 closed 1 year ago

Ernest314 commented 1 year ago

There shouldn't be too much performance impact? Could also heuristically limit autocompletes if the input text is still short (only a few characters).

Ernest314 commented 1 year ago

So far it's /help and /farm, but this will extend to other commands quickly (/tag, possibly anything involving duration).

Ernest314 commented 1 year ago

/mimic also.

Ernest314 commented 1 year ago

Since the new autocompleters don't match on wrong text (but there is rudimentary fuzzy matching), there is no need to calculate edit distance. Instead, results are sorted on match type (e.g. "starts with", "contains", "fuzzy"), and then within each type they are sorted alphabetically.

This might actually end up being better since Discord can't bold the original text in the autocomplete options, so it's kinda more readable to just sort the fuzzy matches alphabetically.