forked from Galactic/galactic-bot
improvements
This commit is contained in:
parent
6ceb1bbe77
commit
71fed41529
@ -7,6 +7,7 @@ const Component = require("./Component.js");
|
|||||||
// Imports to enable JSDocs typing
|
// Imports to enable JSDocs typing
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const InteractionWrapper = require("../client/wrappers/InteractionWrapper.js");
|
const InteractionWrapper = require("../client/wrappers/InteractionWrapper.js");
|
||||||
|
const CommandOption = require('./CommandOption.js');
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
// const { DiscordClient } = require("../DiscordClient.js");
|
// const { DiscordClient } = require("../DiscordClient.js");
|
||||||
|
|
||||||
@ -69,7 +70,28 @@ class Setting extends Component {
|
|||||||
this.default = { [this.name]: options.default || {} };
|
this.default = { [this.name]: options.default || {} };
|
||||||
this.definitions = options.definitions || {}; // Used for the API for field definitions
|
this.definitions = options.definitions || {}; // Used for the API for field definitions
|
||||||
|
|
||||||
this.commandOptions = options.commandOptions || [];
|
this.commandOptions = [];
|
||||||
|
this.commandType = options.commandType || 'SUB_COMMAND';
|
||||||
|
|
||||||
|
if (options.commandOptions)
|
||||||
|
for (const opt of options.commandOptions) {
|
||||||
|
if (opt instanceof CommandOption) this.commandOptions.push(opt);
|
||||||
|
else if (opt.name instanceof Array) {
|
||||||
|
const { name: names, description, type, ...opts } = opt;
|
||||||
|
for (const name of names) {
|
||||||
|
// console.log(name);
|
||||||
|
const index = names.indexOf(name);
|
||||||
|
let desc = description,
|
||||||
|
_type = type;
|
||||||
|
if (description instanceof Array) desc = description[index] || 'Missing description';
|
||||||
|
if (type instanceof Array) {
|
||||||
|
_type = type[index];
|
||||||
|
if (!_type) throw new Error(`Missing type for option ${name} in command ${this.name}`);
|
||||||
|
}
|
||||||
|
this.commandOptions.push(new CommandOption({ name, type: _type, description: desc, ...opts }));
|
||||||
|
}
|
||||||
|
} else this.commandOptions.push(new CommandOption(opt));
|
||||||
|
}
|
||||||
|
|
||||||
this.clientPermissions = options.clientPermissions || [];
|
this.clientPermissions = options.clientPermissions || [];
|
||||||
this.memberPermissions = options.memberPermissions || []; // Idk if we'll end up using this but it's here anyway
|
this.memberPermissions = options.memberPermissions || []; // Idk if we'll end up using this but it's here anyway
|
||||||
@ -91,14 +113,19 @@ class Setting extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// , verbose = false -- unsure if this is a necessary argument anymore
|
// , verbose = false -- unsure if this is a necessary argument anymore
|
||||||
usageEmbed(guild) {
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
usageEmbed(guild, verbose = false, subcommand = null) {
|
||||||
|
|
||||||
const fields = [];
|
const fields = [];
|
||||||
|
let options = this.commandOptions;
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
if (subcommand) options = subcommand.options;
|
||||||
|
|
||||||
|
if (options.length) {
|
||||||
|
|
||||||
if (this.commandOptions.length) {
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: `》 ${guild.format(`GENERAL_OPTIONS`)}`,
|
name: `》 ${guild.format(`GENERAL_OPTIONS`)}`,
|
||||||
value: this.commandOptions.map(
|
value: options.map(
|
||||||
(opt) => {
|
(opt) => {
|
||||||
let msg = `**${opt.name} [${opt.type}]:** ${opt.description}`;
|
let msg = `**${opt.name} [${opt.type}]:** ${opt.description}`;
|
||||||
if (opt.choices.length)
|
if (opt.choices.length)
|
||||||
|
Loading…
Reference in New Issue
Block a user