From 1559d2b332258863ecae1ae659f3eb33cd863338 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 12 Jan 2020 21:22:23 -0500 Subject: [PATCH] Add commands to help with readme building --- Xiao.js | 3 ++- commands/owner/generate-commands.js | 26 ++++++++++++++++++++ commands/owner/generate-credit.js | 37 +++++++++++++++++++++++++++++ commands/util/help.js | 1 + 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 commands/owner/generate-commands.js create mode 100644 commands/owner/generate-credit.js diff --git a/Xiao.js b/Xiao.js index 7fa22a8e..9a6e4b6f 100644 --- a/Xiao.js +++ b/Xiao.js @@ -33,7 +33,8 @@ client.registry ['number-edit', 'Number Manipulation'], ['nsfw', 'NSFW'], ['other', 'Other'], - ['roleplay', 'Roleplay'] + ['roleplay', 'Roleplay'], + ['owner', 'Owner-Only'] ]) .registerDefaultCommands({ help: false, diff --git a/commands/owner/generate-commands.js b/commands/owner/generate-commands.js new file mode 100644 index 00000000..650151bd --- /dev/null +++ b/commands/owner/generate-commands.js @@ -0,0 +1,26 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class GenerateCommandsCommand extends Command { + constructor(client) { + super(client, { + name: 'generate-commands', + aliases: ['gen-commands'], + group: 'owner', + memberName: 'generate-commands', + description: 'Generates the commands list for Xiao\'s README.', + ownerOnly: true, + guarded: true + }); + } + + async run(msg) { + const list = client.registry.groups + .filter(g => g.id !== 'owner') + .map(g => `\n### ${g.name}:\n\n${g.commands.map(c => `* **${c.name}:** ${c.description}`).join('\n')}`); + const { body } = await request + .post('https://hastebin.com/documents') + .send(list.join('\n')); + return msg.say(`https://hastebin.com/raw/${body.key}`); + } +}; diff --git a/commands/owner/generate-credit.js b/commands/owner/generate-credit.js new file mode 100644 index 00000000..ff4e9be1 --- /dev/null +++ b/commands/owner/generate-credit.js @@ -0,0 +1,37 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class GenerateCreditCommand extends Command { + constructor(client) { + super(client, { + name: 'generate-credit', + aliases: ['gen-credit'], + group: 'owner', + memberName: 'generate-credit', + description: 'Generates the credit list for Xiao\'s README.', + ownerOnly: true, + guarded: true + }); + } + + async run(msg) { + const credit = []; + const commands = client.registry.commands.filter(cmd => cmd.credit && cmd.credit.length > 1); + for (const command of commands) { + for (const credit of command.credit) { + const found = credit.find(c => c.name === credit.name); + if (found) { + found.commands.push(command.name); + continue; + }; + if (credit.name === 'Dragon Fire') continue; + credit.push({ ...credit, commands: [command.name] }); + } + } + const mapped = credit.map(c => `- [${c.name}](${c.url})\n${c.commands.map(cmd => ` * ${cmd}`).join('\n')}`); + const { body } = await request + .post('https://hastebin.com/documents') + .send(mapped.join('\n')); + return msg.say(`https://hastebin.com/raw/${body.key}`); + } +}; diff --git a/commands/util/help.js b/commands/util/help.js index 23416320..564dfd4a 100644 --- a/commands/util/help.js +++ b/commands/util/help.js @@ -29,6 +29,7 @@ module.exports = class HelpCommand extends Command { .setColor(0x00AE86) .setFooter(`${this.client.registry.commands.size} Commands`); for (const group of this.client.registry.groups.values()) { + if (group.id === 'owner') continue; embed.addField( `❯ ${group.name}`, group.commands.map(cmd => `\`${cmd.name}\``).join(', ') || 'None'