usage
This commit is contained in:
parent
fea50825e9
commit
e0c6eec092
@ -1,3 +1,5 @@
|
|||||||
|
const { MessageEmbed } = require('discord.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');
|
||||||
const Component = require('../Component.js');
|
const Component = require('../Component.js');
|
||||||
@ -48,29 +50,18 @@ class Command extends Component {
|
|||||||
throw new Error(`${this.resolveable} is missing an execute function.`);
|
throw new Error(`${this.resolveable} is missing an execute function.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
usageEmbed(guild) {
|
usageEmbed(interaction, verbose = false) {
|
||||||
|
|
||||||
const fields = [];
|
const fields = [];
|
||||||
|
const { guild, subcommand } = interaction;
|
||||||
const { permissions: { type } } = guild._settings;
|
const { permissions: { type } } = guild._settings;
|
||||||
|
|
||||||
if (this.options.length) {
|
if (this.options.length) {
|
||||||
fields.push({
|
if (verbose) fields.push(...this.options.map((opt) => opt.usage(guild)));
|
||||||
name: `》 ${guild.format('GENERAL_OPTIONS')}`,
|
else {
|
||||||
value: this.options.map((opt) => {
|
const opt = this.subcommand(subcommand.name);
|
||||||
let msg = `**${opt.name}**`;
|
fields.push(opt.usage(guild));
|
||||||
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 (this.memberPermissions.length) {
|
if (this.memberPermissions.length) {
|
||||||
@ -84,13 +75,13 @@ class Command extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return new MessageEmbed({
|
||||||
author: {
|
author: {
|
||||||
name: `${this.name} [module:${this.module.name}]`
|
name: `${this.name} [module:${this.module.name}]`
|
||||||
},
|
},
|
||||||
description: guild.format(`COMMAND_${this.name.toUpperCase()}_HELP`),
|
description: guild.format(`COMMAND_${this.name.toUpperCase()}_HELP`),
|
||||||
fields
|
fields
|
||||||
};
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user