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-10-18 21:53:35 +00:00
|
|
|
const { buffer, type } = await magick.run({
|
2020-08-28 02:34:12 +00:00
|
|
|
cmd: "motivate",
|
|
|
|
path: image.path,
|
|
|
|
top: topText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'"),
|
2020-10-18 21:53:35 +00:00
|
|
|
bottom: bottomText ? bottomText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'") : ""
|
2020-08-28 02:34:12 +00:00
|
|
|
});
|
2020-09-23 19:12:39 +00:00
|
|
|
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
|
2020-04-12 19:51:48 +00:00
|
|
|
return {
|
2020-07-22 18:12:38 +00:00
|
|
|
file: buffer,
|
2020-10-18 21:53:35 +00:00
|
|
|
name: `motivate.${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";
|