From 8fffd6e28945346a23dcdf299ebfbf3bd7ea1868 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sat, 17 Feb 2018 19:39:58 +0000 Subject: [PATCH] Better help command --- commands/util/help.js | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/commands/util/help.js b/commands/util/help.js index 3276bd16..581461b8 100644 --- a/commands/util/help.js +++ b/commands/util/help.js @@ -1,7 +1,6 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const { stripIndents } = require('common-tags'); -const { util: { disambiguation } } = require('discord.js-commando'); module.exports = class HelpCommand extends Command { constructor(client) { @@ -16,7 +15,7 @@ module.exports = class HelpCommand extends Command { { key: 'command', prompt: 'Which command would you like to view the help for?', - type: 'string', + type: 'command', default: '' } ] @@ -24,29 +23,12 @@ module.exports = class HelpCommand extends Command { } async run(msg, { command }) { - const commands = this.client.registry.findCommands(command, false, msg); - if (command) { - if (commands.length === 1) { - const data = commands[0]; - return msg.say(stripIndents` - __Command **${data.name}**__${data.nsfw ? ' (NSFW)' : ''}${data.guildOnly ? ' (Usable only in servers)' : ''} - ${data.description} ${data.details ? `\n_${data.details}_` : ''} - - **Format**: ${msg.anyUsage(`${data.name} ${data.format || ''}`)} - **Aliases**: ${data.aliases.join(', ') || 'None'} - **Group**: ${data.group.name} (\`${data.groupID}:${data.memberName}\`) - `); - } else if (commands.length > 15) { - return msg.say('Multiple commands found. Please be more specific.'); - } else if (commands.length > 1) { - return msg.say(disambiguation(commands, 'commands')); - } - return msg.say(`Could not identify command. Use ${msg.usage(null)} to view a list of commands.`); - } else { + if (!command) { const embed = new MessageEmbed() .setTitle('Command List') .setDescription(`Use ${msg.usage('')} to view detailed information about a command.`) - .setColor(0x00AE86); + .setColor(0x00AE86) + .setFooter(`${this.client.registry.commands.size} Commands`); for (const group of this.client.registry.groups.values()) { embed.addField(`❯ ${group.name}`, group.commands.map(cmd => cmd.name).join(', ') || 'None'); } @@ -59,5 +41,13 @@ module.exports = class HelpCommand extends Command { return msg.reply('Failed to send DM. You probably have DMs disabled.'); } } + return msg.say(stripIndents` + __Command **${command.name}**__${command.guildOnly ? ' (Usable only in servers)' : ''} + ${command.description}${command.details ? `\n_${command.details}_` : ''} + + **Format**: ${msg.anyUsage(`${command.name} ${command.format || ''}`)} + **Aliases**: ${command.aliases.join(', ') || 'None'} + **Group**: ${command.group.name} (\`${command.groupID}:${command.memberName}\`) + `); } };