usage embed

This commit is contained in:
Erik 2022-01-13 21:51:21 +02:00
parent be5e7f5c72
commit ca271b7590
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589

View File

@ -65,6 +65,8 @@ class Setting extends Component {
this.default = { [this.name]: options.default || {} }; this.default = { [this.name]: options.default || {} };
this.commandOptions = options.commandOptions || [];
} }
/** /**
@ -79,6 +81,37 @@ class Setting extends Component {
hook.collector = await this.collector(wrapper, selectMenu); hook.collector = await this.collector(wrapper, selectMenu);
} }
usageEmbed(guild, verbose = false) {
const fields = [];
if (this.commandOptions.length) {
fields.push({
name: `${guild.format(`GENERAL_OPTIONS`)}`,
value: this.commandOptions.map((opt) => `**${opt.name} [${opt.type}]:** ${opt.description} ${opt.choices.length ? `\n__${guild.format('GENERAL_CHOICES')}__\n\t${opt.choices.map((choice) => choice.name).join('\n\t')}` : ''}`).join('\n')
});
}
return {
author: {
name: `${this.display} [module:${this.module.name}]`
},
description: this.description,
fields
};
}
/**
* Should return fields with current setting values
* @abstract
* @return {Array<void>}
* @memberof Setting
*/
fields() {
return [];
}
/** /**
* Creates an interaction collector that passes the control to onCollect * Creates an interaction collector that passes the control to onCollect
* @param {InteractionWrapper} wrapper Interaction wrapper * @param {InteractionWrapper} wrapper Interaction wrapper