cmd usage related stuff

This commit is contained in:
Erik 2022-04-25 14:09:17 +03:00
parent a72c70c260
commit 4a8c5e4b35
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -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() {