2020-06-18 19:02:35 +00:00
|
|
|
const gm = require("gm").subClass({
|
|
|
|
imageMagick: true
|
|
|
|
});
|
|
|
|
const emojiRegex = require("emoji-regex");
|
|
|
|
const emoji = require("node-emoji");
|
|
|
|
|
|
|
|
exports.run = async (message, args) => {
|
|
|
|
message.channel.sendTyping();
|
|
|
|
const image = await require("../utils/imagedetect.js")(message);
|
|
|
|
if (image === undefined) return `${message.author.mention}, you need to provide an image to overlay a flag onto!`;
|
|
|
|
if (!args[0].match(emojiRegex)) return `${message.author.mention}, you need to provide an emoji of a flag to overlay!`;
|
|
|
|
const flag = emoji.unemojify(args[0]).replace(/:/g, "").replace("flag-", "");
|
2020-06-21 17:12:58 +00:00
|
|
|
let path = `./assets/images/region-flags/png/${flag.toUpperCase()}.png`;
|
2020-06-18 19:02:35 +00:00
|
|
|
if (flag === "🏴☠️") path = "./assets/images/pirateflag.png";
|
2020-06-26 14:36:03 +00:00
|
|
|
const buffer = await gm(image.path).coalesce().out("null:").out("(", path, "-alpha", "set", "-channel", "A", "-evaluate", "multiply", "0.5", "+channel", ")").gravity("North").scale("%[fx:u.w]x%[fx:u.h]!").out("-layers", "composite").bufferPromise(image.type, image.delay);
|
2020-06-18 19:02:35 +00:00
|
|
|
return {
|
|
|
|
file: buffer,
|
|
|
|
name: `flag.${image.type}`
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.params = "[flag]";
|
|
|
|
exports.category = 5;
|
|
|
|
exports.help = "Overlays a flag onto an image";
|