diff --git a/commands/util/generate-commands.js b/commands/util/generate-commands.js index 19c23838..2275005a 100644 --- a/commands/util/generate-commands.js +++ b/commands/util/generate-commands.js @@ -17,9 +17,13 @@ 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 && !c.ownerOnly && !c.nsfw); + const commands = g.commands.filter(c => !c.hidden && !c.ownerOnly); if (!commands.size) return null; - return `\n### ${g.name}:\n\n${commands.map(c => `* **${c.name}:** ${c.description}`).join('\n')}`; + const mapped = commands.map(c => { + const nsfw = c.nsfw ? ` (NSFW)` : ''; + return `* **${c.name}:** ${c.description}${nsfw}`; + }); + return `\n### ${g.name}:\n\n${mapped.join('\n')}`; }) .filter(cmds => cmds); const text = `Total: ${this.client.registry.commands.size}\n${list.join('\n')}`; diff --git a/commands/util/generate-credit.js b/commands/util/generate-credit.js new file mode 100644 index 00000000..9d4133ec --- /dev/null +++ b/commands/util/generate-credit.js @@ -0,0 +1,33 @@ +const Command = require('../../framework/Command'); + +module.exports = class GenerateCreditCommand extends Command { + constructor(client) { + super(client, { + name: 'generate-credit', + aliases: ['gen-credit', 'generate-cred', 'gen-cred'], + group: 'util', + memberName: 'generate-credti', + description: 'Generates the credits list as a TXT file.', + details: 'Only the bot owner(s) may use this command.', + ownerOnly: true, + guarded: true + }); + } + + async run(msg) { + const list = this.client.registry.groups + .map(g => { + const commands = g.commands.filter(c => !c.hidden && !c.ownerOnly && c.credit.length - 1 !== 0); + if (!commands.size) return null; + return commands.map(c => { + const credits = c.credit + .filter(cred => cred.name !== 'Dragon Fire') + .map(cred => `[${cred.name}](${cred.url}) (${cred.reason})`); + return `* **${c.name}:**\n - ${credits.join('\n - ')}`; + }).join('\n'); + }) + .filter(cmds => cmds); + await msg.direct({ files: [{ attachment: Buffer.from(list.join('\n')), name: 'credits.txt' }] }); + return msg.say('📬 Sent `credits.txt` to your DMs!'); + } +};