Add command to generate credit

This commit is contained in:
Dragon Fire
2024-03-27 18:23:13 -04:00
parent b73c7cfa8d
commit bb86962a91
2 changed files with 39 additions and 2 deletions
+6 -2
View File
@@ -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')}`;
+33
View File
@@ -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!');
}
};