2020-08-28 02:34:12 +00:00
|
|
|
const magick = require("../utils/image.js");
|
2020-02-13 19:29:42 +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 make a motivational poster!`;
|
2020-04-23 22:38:01 +00:00
|
|
|
const newArgs = args.filter(item => !item.includes(image.url) );
|
2020-02-13 19:29:42 +00:00
|
|
|
if (args.length === 0) return `${message.author.mention}, you need to provide some text to make a motivational poster!`;
|
|
|
|
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
|
2020-04-23 22:38:01 +00:00
|
|
|
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
|
2020-08-28 02:34:12 +00:00
|
|
|
const buffer = await magick({
|
|
|
|
cmd: "motivate",
|
|
|
|
path: image.path,
|
|
|
|
top: topText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'"),
|
|
|
|
bottom: bottomText ? bottomText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'") : "",
|
|
|
|
type: image.type.toUpperCase(),
|
|
|
|
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
|
|
|
});
|
2020-02-21 00:26:49 +00:00
|
|
|
processMessage.delete();
|
2020-04-12 19:51:48 +00:00
|
|
|
return {
|
2020-07-22 18:12:38 +00:00
|
|
|
file: buffer,
|
2020-02-25 20:45:47 +00:00
|
|
|
name: `motivate.${image.type}`
|
2020-04-12 19:51:48 +00:00
|
|
|
};
|
2020-02-13 19:29:42 +00:00
|
|
|
};
|
|
|
|
|
2020-04-25 04:21:05 +00:00
|
|
|
exports.aliases = ["motivational", "motiv", "demotiv", "demotivational", "poster", "motivation"];
|
2020-02-13 19:29:42 +00:00
|
|
|
exports.category = 5;
|
2020-03-15 23:54:57 +00:00
|
|
|
exports.help = "Creates a motivational poster";
|