This commit is contained in:
Erik 2022-03-31 01:26:43 +03:00
parent fea50825e9
commit e0c6eec092
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -1,3 +1,5 @@
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const DiscordClient = require('../../DiscordClient.js');
const Component = require('../Component.js');
@ -48,29 +50,18 @@ class Command extends Component {
throw new Error(`${this.resolveable} is missing an execute function.`);
}
usageEmbed(guild) {
usageEmbed(interaction, verbose = false) {
const fields = [];
const { guild, subcommand } = interaction;
const { permissions: { type } } = guild._settings;
if (this.options.length) {
fields.push({
name: `${guild.format('GENERAL_OPTIONS')}`,
value: this.options.map((opt) => {
let msg = `**${opt.name}**`;
if (opt.choices.length)
msg += `\n__${guild.format('GENERAL_CHOICES')}__: ${opt.choices.map((choice) => choice.name).join(', ')}`;
if (opt.dependsOn.length)
msg += `\n${guild.format('GENERAL_DEPENDSON', { dependencies: opt.dependsOn.join('`, `') })}`;
if (opt.minimum !== undefined)
msg += `\nMIN: \`${opt.minimum}\``;
if (opt.maximum !== undefined) {
const newline = opt.minimum !== undefined ? ', ' : '\n';
msg += `${newline}MAX: \`${opt.maximum}\``;
}
return msg;
}).join('\n\n')
});
if (verbose) fields.push(...this.options.map((opt) => opt.usage(guild)));
else {
const opt = this.subcommand(subcommand.name);
fields.push(opt.usage(guild));
}
}
if (this.memberPermissions.length) {
@ -84,13 +75,13 @@ class Command extends Component {
});
}
return {
return new MessageEmbed({
author: {
name: `${this.name} [module:${this.module.name}]`
},
description: guild.format(`COMMAND_${this.name.toUpperCase()}_HELP`),
fields
};
});
}