Im not sure if this question has been posted yet but here is what i wanna make:
So im trying to make something that find the nearest result of an argument.(Discord.js v13) But i have no idea on how to make it,is there a Code or an API for this feature?
For example:
!find rock If Rock is in the bot list,then it will say something like “Rock is bla bla bla”.If it is not in the bot it will say something like “Rock is unknown!Did you mean Rack , Dock , Etc if theres more on the bot.”
another example: !find rok that is an typo so it will also do the same thing. “Rok is unknown!Did you mean Rock , Etc“
Would like to get some help on this!
Advertisement
Answer
This website is mostly for answering questions that have context like code snippets and additional context, so I suggest you do that next time.
For now, a few ways you might do this.
- Save the items somewhere, like in a JSON file, or other database. A quick google search will show you how to do this.
- You can look to see if the entry is in the database, but for other things like fuzzy search, you would want to use something like Minisearch or Fuse.js.
- As in “did you mean” checking, I don’t think it’s necessary. If you are using fuzzy search and there are no results, there will be no did-you-means. If you are just looking at the JSON or db, you would need to use fuzzy search for DYMs.