From 9085a651ea576b4deaa46af56923adfa92726e74 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 21 Mar 2021 11:35:15 -0400 Subject: [PATCH] Filter stuff out of generate-commands --- commands/single/hello-world.js | 16 ++++++++++++++++ commands/util/generate-commands.js | 13 ++++++------- package.json | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 commands/single/hello-world.js diff --git a/commands/single/hello-world.js b/commands/single/hello-world.js new file mode 100644 index 00000000..9173db90 --- /dev/null +++ b/commands/single/hello-world.js @@ -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!'); + } +}; diff --git a/commands/util/generate-commands.js b/commands/util/generate-commands.js index 2d1ccdae..8eec090f 100644 --- a/commands/util/generate-commands.js +++ b/commands/util/generate-commands.js @@ -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!'); diff --git a/package.json b/package.json index a8e2680f..09963ccf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "132.10.0", + "version": "132.11.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {