2019-10-24 18:54:23 +00:00
|
|
|
const gm = require("gm").subClass({
|
|
|
|
imageMagick: true
|
|
|
|
});
|
|
|
|
const gmToBuffer = require("../utils/gmbuffer.js");
|
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
exports.run = async (message) => {
|
2019-12-02 20:47:22 +00:00
|
|
|
message.channel.sendTyping();
|
2019-10-24 18:54:23 +00:00
|
|
|
const image = await require("../utils/imagedetect.js")(message);
|
|
|
|
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Trump meme!`;
|
|
|
|
const template = "./assets/images/trump.png";
|
2019-10-28 16:02:00 +00:00
|
|
|
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
2019-11-11 20:54:19 +00:00
|
|
|
require("util").promisify(fs.writeFile)(path, image.data);
|
2019-10-24 18:54:23 +00:00
|
|
|
const command = gm(template).out("-background").out("none").out("-gravity").out("South").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("365x179!").out("+distort").out("Perspective").out("0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").out("-geometry").out("-25-1").out("-composite").out(")").out("+swap").out("-composite");
|
2019-11-11 20:54:19 +00:00
|
|
|
const resultBuffer = await gmToBuffer(command, "png");
|
2019-10-24 18:54:23 +00:00
|
|
|
return message.channel.createMessage("", {
|
|
|
|
file: resultBuffer,
|
|
|
|
name: "trump.png"
|
|
|
|
});
|
2019-12-02 20:47:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.category = 5;
|
|
|
|
exports.help = "Makes Trump display an image";
|