Add aliases to did you mean

This commit is contained in:
Dragon Fire
2020-03-01 15:04:09 -05:00
parent 5580376eed
commit 13d6777943
+12 -1
View File
@@ -16,7 +16,7 @@ module.exports = class UnknownCommandCommand extends Command {
}
run(msg) {
const commands = this.client.registry.commands.map(c => c.name);
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 inGuild = msg.guild ? undefined : null;
@@ -26,4 +26,15 @@ module.exports = class UnknownCommandCommand extends Command {
${didYouMean && didYouMean.length ? `Did You Mean: ${didYouMean.map(c => `\`${c}\``).join(',')}` : ''}
`);
}
makeCommandArray(owner) {
const arr = [];
for (const command of this.client.registry.commands.values()) {
if (!owner && command.ownerOnly) continue;
if (command.hidden) continue;
arr.push(command.name);
arr.push(...command.aliases);
}
return arr;
}
};