How do i make an entire array an autocomplete?

I have a huge array and I want it to be autocomplete for a command how would i go about implementing that into a AutocompleteHandler ?
Solution:
first of all, you have to limit it to 25(? i forgot the max) results secondly, you just return the array in the proper order, and you sort it by using a fuzzy searching algorithm such as Jaro Wrinkler (use @Skyra/jaro-wrinkler for example)...
Jump to solution
7 Replies
Solution
Favna
Favna2y ago
first of all, you have to limit it to 25(? i forgot the max) results secondly, you just return the array in the proper order, and you sort it by using a fuzzy searching algorithm such as Jaro Wrinkler (use @Skyra/jaro-wrinkler for example)
Spinel
Spinel2y ago
@skyra/jaro-winkler
A string similarity utility that uses the Jaro-Winkler algorithm ❯ Author: skyra-project ❯ Maintainers: favna and kyranet ❯ Latest version: 1.1.0 ❯ License: MIT ❯ Date Created: <t:1633979242:d> ❯ Date Modified: <t:1649289986:d> Dependencies: No dependencies <:_:637706251253317669>
Lioness100
Lioness1002y ago
I recommend using fuse.js just because it's a bit simpler (here's an example that only takes 2 lines of code for a reload command): https://github.com/Lioness100/jampbot-v3/blob/f40cc46b5b4b4b7f9a88de021051e53fd47ec064/src/commands/dev/reload.ts#L61-L62
GitHub
jampbot-v3/reload.ts at f40cc46b5b4b4b7f9a88de021051e53fd47ec064 · ...
A feature-rich discord bot created for Team Jamp. Contribute to Lioness100/jampbot-v3 development by creating an account on GitHub.
Favna
Favna2y ago
yeah fuse is another good option (also btw I know of the option: https://github.com/krisk/Fuse/commits/master?author=favna)
Lioness100
Lioness1002y ago
Ok well so if we're making this a popularity competition, I contributed to google ablobnod was rad af
Favna
Favna2y ago
lol
Want results from more Discord servers?
Add your server