diff --git a/src/structure/interfaces/commands/Command.js b/src/structure/interfaces/commands/Command.js index 84b59a9..db2acf0 100644 --- a/src/structure/interfaces/commands/Command.js +++ b/src/structure/interfaces/commands/Command.js @@ -1,3 +1,5 @@ +const { MessageEmbed } = require('discord.js'); + // eslint-disable-next-line no-unused-vars const DiscordClient = require('../../DiscordClient.js'); const Component = require('../Component.js'); @@ -48,29 +50,18 @@ class Command extends Component { throw new Error(`${this.resolveable} is missing an execute function.`); } - usageEmbed(guild) { + usageEmbed(interaction, verbose = false) { const fields = []; + const { guild, subcommand } = interaction; const { permissions: { type } } = guild._settings; if (this.options.length) { - fields.push({ - name: `》 ${guild.format('GENERAL_OPTIONS')}`, - value: this.options.map((opt) => { - let msg = `**${opt.name}**`; - if (opt.choices.length) - msg += `\n__${guild.format('GENERAL_CHOICES')}__: ${opt.choices.map((choice) => choice.name).join(', ')}`; - if (opt.dependsOn.length) - msg += `\n${guild.format('GENERAL_DEPENDSON', { dependencies: opt.dependsOn.join('`, `') })}`; - if (opt.minimum !== undefined) - msg += `\nMIN: \`${opt.minimum}\``; - if (opt.maximum !== undefined) { - const newline = opt.minimum !== undefined ? ', ' : '\n'; - msg += `${newline}MAX: \`${opt.maximum}\``; - } - return msg; - }).join('\n\n') - }); + if (verbose) fields.push(...this.options.map((opt) => opt.usage(guild))); + else { + const opt = this.subcommand(subcommand.name); + fields.push(opt.usage(guild)); + } } if (this.memberPermissions.length) { @@ -84,13 +75,13 @@ class Command extends Component { }); } - return { + return new MessageEmbed({ author: { name: `${this.name} [module:${this.module.name}]` }, description: guild.format(`COMMAND_${this.name.toUpperCase()}_HELP`), fields - }; + }); }