2020-07-23 20:49:34 +00:00
|
|
|
const magick = require("../build/Release/image.node");
|
|
|
|
const { promisify } = require("util");
|
2020-01-08 01:17:04 +00:00
|
|
|
|
|
|
|
exports.run = async (message, args) => {
|
|
|
|
const image = await require("../utils/imagedetect.js")(message);
|
|
|
|
if (image === undefined) return `${message.author.mention}, you need to provide an image/GIF to add a caption!`;
|
2020-04-23 22:38:01 +00:00
|
|
|
const newArgs = args.filter(item => !item.includes(image.url) );
|
2020-01-09 01:10:26 +00:00
|
|
|
if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`;
|
2020-01-08 01:17:04 +00:00
|
|
|
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
|
2020-07-23 20:49:34 +00:00
|
|
|
const outputFinal = await promisify(magick.caption)(newArgs.join(" "), image.path, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
2020-02-21 00:26:49 +00:00
|
|
|
await processMessage.delete();
|
2020-04-12 19:51:48 +00:00
|
|
|
return {
|
2020-02-21 00:26:49 +00:00
|
|
|
file: outputFinal,
|
2020-02-25 20:45:47 +00:00
|
|
|
name: `caption.${image.type}`
|
2020-04-12 19:51:48 +00:00
|
|
|
};
|
2020-01-08 01:17:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.aliases = ["gifc", "gcaption", "ifcaption", "ifunnycaption"];
|
|
|
|
exports.category = 5;
|
2020-03-05 15:28:10 +00:00
|
|
|
exports.help = "Adds a caption to an image/GIF";
|