mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add aliases to did you mean
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user