Filter stuff out of generate-commands

This commit is contained in:
Dragon Fire
2021-03-21 11:35:15 -04:00
parent 2a0bf3d374
commit 9085a651ea
3 changed files with 23 additions and 8 deletions
+16
View File
@@ -0,0 +1,16 @@
const Command = require('../../structures/Command');
module.exports = class HelloWorldCommand extends Command {
constructor(client) {
super(client, {
name: 'hello-world',
group: 'single',
memberName: 'hello-world',
description: 'Hello world!'
});
}
run(msg) {
return msg.say('Hello, world!');
}
};
+6 -7
View File
@@ -7,7 +7,7 @@ module.exports = class GenerateCommandsCommand extends Command {
aliases: ['gen-commands', 'generate-cmds', 'gen-cmds'],
group: 'util',
memberName: 'generate-commands',
description: 'Generates the commands list for Xiao\'s README.',
description: 'Generates the commands list as a TXT file.',
details: 'Only the bot owner(s) may use this command.',
ownerOnly: true,
guarded: true
@@ -17,12 +17,11 @@ module.exports = class GenerateCommandsCommand extends Command {
async run(msg) {
const list = this.client.registry.groups
.map(g => {
const commands = g.commands.filter(c => !c.hidden);
return `\n### ${g.name}:\n\n${commands.map(c => {
const extra = `${c.ownerOnly ? ' (Owner-Only)' : ''}${c.nsfw ? ' (NSFW)' : ''}`;
return `* **${c.name}:** ${c.description}${extra}`;
}).join('\n')}`;
});
const commands = g.commands.filter(c => !c.hidden && !c.ownerOnly && !c.nsfw);
if (!commands.size) return null;
return `\n### ${g.name}:\n\n${commands.map(c => `* **${c.name}:** ${c.description}`).join('\n')}`;
})
.filter(cmds => cmds);
const text = `Total: ${this.client.registry.commands.size}\n${list.join('\n')}`;
await msg.direct({ files: [{ attachment: Buffer.from(text), name: 'commands.txt' }] });
return msg.say('📬 Sent `commands.txt` to your DMs!');
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "132.10.0",
"version": "132.11.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {