forked from Galactic/galactic-bot
refined the commands command
This commit is contained in:
parent
f412e1c3b3
commit
d0381bbe30
@ -1,4 +1,5 @@
|
||||
const { Emojis } = require("../../../../constants");
|
||||
const { Util } = require("../../../../utilities");
|
||||
const { SlashCommand } = require("../../../interfaces");
|
||||
|
||||
class Commands extends SlashCommand {
|
||||
@ -30,6 +31,7 @@ class Commands extends SlashCommand {
|
||||
if (module) commands = module.value.components.filter((c) => c._type === 'command');
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
else commands = this.client.registry.commands;
|
||||
const amt = commands.size;
|
||||
|
||||
const modules = {};
|
||||
for (const command of commands.values()) {
|
||||
@ -37,21 +39,25 @@ class Commands extends SlashCommand {
|
||||
const _module = command.module.name;
|
||||
if (!modules[_module]) modules[_module] = [];
|
||||
const emoji = disabled?.includes(command.resolveable) ? Emojis.failure : Emojis.success;
|
||||
modules[_module].push(`${emoji} ${command.name}`);
|
||||
modules[_module].push(`${emoji} ${Util.capitalise(command.name)}`);
|
||||
}
|
||||
|
||||
const embed = {
|
||||
title: guild.format('COMMAND_COMMANDS_TITLE'),
|
||||
fields: []
|
||||
fields: [],
|
||||
footer: { text: `• ${amt} commands` }
|
||||
};
|
||||
for (const [module, commands] of Object.entries(modules).sort(([, a], [, b]) => a.length - b.length)) {
|
||||
embed.fields.push({
|
||||
name: module,
|
||||
name: Util.capitalise(module),
|
||||
value: commands.join('\n'),
|
||||
inline: true
|
||||
});
|
||||
}
|
||||
|
||||
embed.fields.sort((a, b) => b.value.length - a.value.length);
|
||||
if (embed.fields.length % 3 > 0) embed.fields.push({ name: '\u200b', value: '\u200b', inline: true });
|
||||
|
||||
return invoker.reply({ embed });
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user