import { Command } from 'discord-akairo'; import { Message } from 'discord.js'; import { colour } from '../../Config'; export default class HelpUtil extends Command { public constructor() { super('help', { aliases: ['help'], category: 'utility', description: { content: 'List help features or get information on a specified command.', usage: '[command]', examples: [ '', '8ball' ] }, ratelimit: 3, clientPermissions: ['EMBED_LINKS'], args: [ { id: 'command', type: 'commandAlias', prompt: { start: 'Which command do you need help with?', retry: 'Please provide a valid command.', optional: true }, match: 'rest' } ] }); } public exec(msg: Message, { command }): Promise { if (!command) { const embed = this.client.util.embed() .setColor(colour) .addFields([ { name: 'Online Command List', value: '*Coming soon!*' }, { name: 'Specific Command Help', value: `${this.handler.prefix}help ` }, { name: 'List of all public categories', value: `${this.handler.prefix}categories` } ]); return msg.channel.send({ embed }); } const description = Object.assign({ content: 'No description available.', usage: '', examples: [], fields: [] }, command.description); const embed = this.client.util.embed() .setColor(colour) .setTitle(`\`${this.client.commandHandler.prefix}${command.aliases[0]} ${description.usage}\``) .addField('Description', description.content); for (const field of description.fields) embed.addField(field.name, field.value); if (command.aliases.length > 1) { embed.addField('Aliases', `\`${command.aliases.join('`, `')}\``, true); } if (command.description.examples.length >= 1) { embed.addField('Examples', `\`${this.client.commandHandler.prefix}${command.aliases[0]} ${command.description.examples.join(`, ${this.client.commandHandler.prefix}${command.aliases[0]} `)}\``, true); } if (command.userPermissions) { embed.addField('User permission', `\`${command.userPermissions.join('` `')}\``, true); } if (command.clientPermissions) { embed.addField('Bot permission', `\`${command.clientPermissions.join('` `')}\``, true); } if (command.contentParser.flagWords.length) { embed.addField('Command flags', `\`${command.contentParser.flagWords.join('` `')}\``, true); } if (command.contentParser.optionFlagWords.length) { embed.addField('Command options flags', `\`${command.contentParser.optionFlagWords.join('` `')}\``, true); } if (msg.channel.type === 'dm') return msg.author.send({ embed }); return msg.reply('Sending you a DM with information...').then(async m => { await msg.author.send({ embed }); m.edit('I\'ve send you a DM with information!'); }); } }