Use didyoumean2 instead of meant

This commit is contained in:
Dragon Fire
2020-03-01 21:03:10 -05:00
parent 874d9e747a
commit 826c5ce99b
2 changed files with 7 additions and 6 deletions
+4 -3
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command');
const meant = require('meant');
const { default: didYouMean, ReturnTypeEnums } = require('didyoumean2');
const { stripIndents } = require('common-tags');
module.exports = class UnknownCommandCommand extends Command {
@@ -18,12 +18,13 @@ module.exports = class UnknownCommandCommand extends Command {
run(msg) {
const commands = this.makeCommandArray(this.client.isOwner(msg.author));
const command = msg.content.match(this.client.dispatcher._commandPatterns[this.client.commandPrefix]);
const didYouMean = meant(command ? command[2] : msg.content.split(' ')[0], commands);
const str = command ? command[2] : msg.content.split(' ')[0];
const results = didYouMean(str, commands, { returnType: ReturnTypeEnums.ALL_SORTED_MATCHES });
const inGuild = msg.guild ? undefined : null;
return msg.reply(stripIndents`
Unknown command. Use ${msg.anyUsage('help', inGuild, inGuild)} to view the command list.
${didYouMean && didYouMean.length ? `Did You Mean: ${didYouMean.map(c => `\`${c}\``).join(',')}` : ''}
${results ? `Did You Mean: ${results.slice(0, 5).map(c => `\`${c}\``).join(',')}` : ''}
`);
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "111.1.1",
"version": "111.1.2",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
@@ -39,12 +39,12 @@
"cloc": "^2.5.1",
"common-tags": "^1.8.0",
"custom-translate": "^2.2.8",
"discord.js": "^12.0.0",
"didyoumean2": "^4.0.0",
"discord.js": "^12.0.1",
"discord.js-commando": "github:discordjs/Commando",
"dotenv": "^8.2.0",
"gifencoder": "^2.0.1",
"mathjs": "^6.6.1",
"meant": "^1.0.1",
"moment": "^2.24.0",
"moment-duration-format": "^2.3.2",
"moment-timezone": "^0.5.28",