diff --git a/commands/util/unknown-command.js b/commands/util/unknown-command.js index 29efdc9b..a617dab8 100644 --- a/commands/util/unknown-command.js +++ b/commands/util/unknown-command.js @@ -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(',')}` : ''} `); } diff --git a/package.json b/package.json index ece3141e..2618a9ff 100644 --- a/package.json +++ b/package.json @@ -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",