diff --git a/src/structure/interfaces/commands/Command.js b/src/structure/interfaces/commands/Command.js index cdd936d..3d50cb2 100644 --- a/src/structure/interfaces/commands/Command.js +++ b/src/structure/interfaces/commands/Command.js @@ -3,7 +3,7 @@ const { MessageEmbed } = require('discord.js'); // eslint-disable-next-line no-unused-vars const DiscordClient = require('../../DiscordClient.js'); const Component = require('../Component.js'); -const { CommandOption } = require('../index.js'); +const CommandOption = require('../CommandOption.js'); class Command extends Component { @@ -75,14 +75,17 @@ class Command extends Component { usageEmbed(invoker, verbose = false) { const fields = []; - const { guild, subcommand } = invoker; + const { guild, subcommand, subcommandGroup } = invoker; const { permissions: { type } } = guild._settings; if (this.options.length) { if (verbose) fields.push(...this.options.map((opt) => opt.usage(guild))); - else if(subcommand) { + else if (subcommand) { const opt = this.subcommand(subcommand.name); fields.push(opt.usage(guild)); + } else if (subcommandGroup) { + const opt = this.subcommandGroup(subcommandGroup.name); + fields.push(opt.usage(guild)); } } @@ -107,10 +110,20 @@ class Command extends Component { } + subcommandGroup(name) { + if (!name) return null; + name = name.toLowerCase(); + return this.subcommandGroups.find((group) => group.name === name); + } + + get subcommandGroups() { + return this.options.filter((opt) => opt.type === 'SUB_COMMAND_GROUP'); + } + subcommand(name) { if (!name) return null; name = name.toLowerCase(); - return this.subcommands.find((cmd) => cmd.name.toLowerCase() === name); + return this.subcommands.find((cmd) => cmd.name === name); } get subcommands() {