switchblade
switchblade copied to clipboard
"Did you mean?" option for command typos
Let's say someone types s!showertoughts. Currently, as it's not a valid command, the bot wouldn't do anything, and the user might get confused.
A good solution to that is allowing server owners to turn on a "did you mean" feature, that could use https://fusejs.io/ to find the closest match to what the user just typed and send a message like this on the channel:
Did you mean
s!showerthoughts?
ps: this should be guild-configurable. iirc, Discord Bot List and some servers like those don't like that much when that happens
A good solution to that is allowing server owners to turn on a "did you mean" feature
Opt-in, yeah
const commandList = ['showerthoughts', 'furry', 'e621', 'play', 'queue']
const Fuse = require('fuse.js')
const fuse = new Fuse(commandList, { shouldSort: true, threshold: 0.6, location: 0, distance: 100, maxPatternLength: 32, minMatchCharLength: 1 })
const result = fuse.search("queeu")
// It should return "[ 4 ]", meaning that result[0] is going to return the position in which the command is more reliable to be what the user wanted to pick. The usage for that is commandList[`${result[0]}`], or something more clean.
Yup, that looks good
I've used Fuse for the LoR commands btw, give them a look
Not possible due the new discord bot system