diff --git a/commands/util/unknown-command.js b/commands/util/unknown-command.js index 84bff03c..29efdc9b 100644 --- a/commands/util/unknown-command.js +++ b/commands/util/unknown-command.js @@ -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; + } };