Add commands to help with readme building

This commit is contained in:
Dragon Fire
2020-01-12 21:22:23 -05:00
parent c9aa58cea1
commit 1559d2b332
4 changed files with 66 additions and 1 deletions
+2 -1
View File
@@ -33,7 +33,8 @@ client.registry
['number-edit', 'Number Manipulation'],
['nsfw', 'NSFW'],
['other', 'Other'],
['roleplay', 'Roleplay']
['roleplay', 'Roleplay'],
['owner', 'Owner-Only']
])
.registerDefaultCommands({
help: false,
+26
View File
@@ -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}`);
}
};
+37
View File
@@ -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}`);
}
};
+1
View File
@@ -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'