mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-14 08:08:34 +02:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
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 = this.client.registry.commands.filter(cmd => cmd.credit && cmd.credit.length > 1);
|
|
for (const command of commands.values()) {
|
|
for (const cred of command.credit) {
|
|
const found = credit.find(c => c.name === cred.name);
|
|
if (found) {
|
|
found.commands.push(command.name);
|
|
continue;
|
|
};
|
|
if (cred.name === 'Dragon Fire') continue;
|
|
credit.push({ ...cred, 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}`);
|
|
}
|
|
};
|