mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Add command to generate credit
This commit is contained in:
@@ -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')}`;
|
||||
|
||||
@@ -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!');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user