animated emoji support

will it work?
This commit is contained in:
Lamp 2020-04-09 22:21:59 -07:00
parent e5d38541f8
commit da4c75f654

@ -319,7 +319,17 @@ client.on("message", async message => {
await message.channel.send(new Discord.Attachment(cachedpath));
} else {
let emojibuf = (await require('snekfetch').get(emoji.url)).body;
let rszbuf = await require('sharp')(emojibuf).resize(48,48,{fit:'inside'}).toBuffer();
let rszbuf;
if (emoji.animated) {
rszbuf = await new Promise(function(resolve,reject){
require("child_process").execFile("gifsicle", ['-', '--resize-touch', '48x48'], function(err,stdout,stderr){
if (err) return reject(err);
resolve(stdout);
}).stdin.write(emojibuf);
});
} else {
rszbuf = await require('sharp')(emojibuf).resize(48,48,{fit:'inside'}).toBuffer();
}
await message.channel.send(new Discord.Attachment(rszbuf, `${emoji.name}.${emoji.url.split('.').pop()}`));
fs.writeFileSync(cachedpath, rszbuf);
}