Emoji Zip Command

This commit is contained in:
Dragon Fire
2021-03-28 21:42:13 -04:00
parent e37763bae8
commit d04d8df328
2 changed files with 34 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const JSZip = require('jszip');
module.exports = class EmojiZipCommand extends Command {
constructor(client) {
super(client, {
name: 'emoji-zip',
aliases: ['emojis-zip', 'emotes-zip', 'e-zip'],
group: 'info',
memberName: 'emoji-zip',
description: 'Responds with a ZIP file of the server\'s custom emoji.',
throttling: {
usages: 1,
duration: 60
},
guildOnly: true
});
}
async run(msg) {
const emojis = msg.guild.emojis.cache;
if (!emojis.size) return msg.say('This server has no custom emoji.');
const zip = new JSZip();
await Promise.all(emojis.map(async emoji => {
const { body } = await request.get(emoji.url);
const format = emoji.animated ? 'gif' : 'png';
zip.file(`${emoji.id}.${format}`, body);
}));
const zipped = await zip.generateAsync({ type: 'nodebuffer' });
return msg.say({ files: [{ attachment: zipped, name: 'emoji.zip' }] });
}
};
+1
View File
@@ -60,6 +60,7 @@
"ioredis": "^4.24.5",
"js-beautify": "^1.13.5",
"js-chess-engine": "^0.11.1",
"jszip": "^3.6.0",
"kuroshiro": "^1.1.2",
"kuroshiro-analyzer-kuromoji": "^1.1.0",
"mathjs": "^9.3.0",