cmd usage related stuff
This commit is contained in:
parent
a72c70c260
commit
4a8c5e4b35
@ -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,7 +75,7 @@ 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) {
|
||||
@ -83,6 +83,9 @@ class Command extends Component {
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user