mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 02:15:10 +02:00
Use didyoumean2 instead of meant
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const meant = require('meant');
|
const { default: didYouMean, ReturnTypeEnums } = require('didyoumean2');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
|
|
||||||
module.exports = class UnknownCommandCommand extends Command {
|
module.exports = class UnknownCommandCommand extends Command {
|
||||||
@@ -18,12 +18,13 @@ module.exports = class UnknownCommandCommand extends Command {
|
|||||||
run(msg) {
|
run(msg) {
|
||||||
const commands = this.makeCommandArray(this.client.isOwner(msg.author));
|
const commands = this.makeCommandArray(this.client.isOwner(msg.author));
|
||||||
const command = msg.content.match(this.client.dispatcher._commandPatterns[this.client.commandPrefix]);
|
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;
|
const inGuild = msg.guild ? undefined : null;
|
||||||
return msg.reply(stripIndents`
|
return msg.reply(stripIndents`
|
||||||
Unknown command. Use ${msg.anyUsage('help', inGuild, inGuild)} to view the command list.
|
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
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "111.1.1",
|
"version": "111.1.2",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -39,12 +39,12 @@
|
|||||||
"cloc": "^2.5.1",
|
"cloc": "^2.5.1",
|
||||||
"common-tags": "^1.8.0",
|
"common-tags": "^1.8.0",
|
||||||
"custom-translate": "^2.2.8",
|
"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",
|
"discord.js-commando": "github:discordjs/Commando",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"gifencoder": "^2.0.1",
|
"gifencoder": "^2.0.1",
|
||||||
"mathjs": "^6.6.1",
|
"mathjs": "^6.6.1",
|
||||||
"meant": "^1.0.1",
|
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"moment-duration-format": "^2.3.2",
|
"moment-duration-format": "^2.3.2",
|
||||||
"moment-timezone": "^0.5.28",
|
"moment-timezone": "^0.5.28",
|
||||||
|
|||||||
Reference in New Issue
Block a user