2020-02-21 00:26:49 +00:00
|
|
|
const {
|
|
|
|
exec
|
|
|
|
} = require("child_process");
|
2020-02-13 19:29:42 +00:00
|
|
|
const util = require("util");
|
|
|
|
const gm = require("gm").subClass({
|
|
|
|
imageMagick: true
|
|
|
|
});
|
|
|
|
|
|
|
|
exports.run = async (message) => {
|
|
|
|
message.channel.sendTyping();
|
|
|
|
const image = await require("../utils/imagedetect.js")(message);
|
|
|
|
if (image === undefined) return `${message.author.mention}, you need to provide a GIF to speed up!`;
|
2020-02-25 20:45:47 +00:00
|
|
|
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
|
2020-02-21 00:26:49 +00:00
|
|
|
const value = await gm(image.path).identifyPromise();
|
|
|
|
const delay = value.Delay ? value.Delay[0].split("x") : [0, 100];
|
|
|
|
if (Math.round(parseInt(delay[0]) / 2) >= 2) {
|
2020-02-25 20:45:47 +00:00
|
|
|
const buffer = await gm().delay(`${parseInt(delay[0]) / 2}x${delay[1]}`).out(image.path).bufferPromise(image.type);
|
2020-02-21 00:26:49 +00:00
|
|
|
return message.channel.createMessage("", {
|
|
|
|
file: buffer,
|
|
|
|
name: "speed.gif"
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const numbers = (await util.promisify(exec)(`seq 0 2 ${value.Scene.length}`)).stdout.split("\n").join(",");
|
2020-02-25 20:45:47 +00:00
|
|
|
const buffer = await gm().out("(").out(image.path).coalesce().out(")").out("-delete", numbers).bufferPromise(image.type);
|
2020-02-21 00:26:49 +00:00
|
|
|
return message.channel.createMessage("", {
|
|
|
|
file: buffer,
|
|
|
|
name: "speed.gif"
|
|
|
|
});
|
|
|
|
}
|
2020-02-13 19:29:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.aliases = ["speedup", "fast", "gifspeed"];
|
|
|
|
exports.category = 5;
|
|
|
|
exports.help = "Makes a GIF faster";
|