mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 22:44:32 +02:00
Fix lots of code dupe
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const gm = require('gm').subClass({ imageMagick: true });
|
||||
const request = require('node-superfetch');
|
||||
const { magikToBuffer } = require('../../util/Util');
|
||||
|
||||
module.exports = class ImplodeCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -45,20 +46,11 @@ module.exports = class ImplodeCommand extends Command {
|
||||
const magik = gm(body);
|
||||
magik.implode(level / 100);
|
||||
magik.setFormat('png');
|
||||
const attachment = await this.toBuffer(magik);
|
||||
const attachment = await magikToBuffer(magik);
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'implode.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
toBuffer(magik) {
|
||||
return new Promise((res, rej) => {
|
||||
magik.toBuffer((err, buffer) => {
|
||||
if (err) return rej(err);
|
||||
return res(buffer);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user