2020-08-28 02:34:12 +00:00
|
|
|
const magick = require("../utils/image.js");
|
2020-07-27 00:52:13 +00:00
|
|
|
const fs = require("fs");
|
2020-06-18 19:02:35 +00:00
|
|
|
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!`;
|
2021-02-25 21:10:03 +00:00
|
|
|
if (args.length === 0 || !args[0].match(emojiRegex)) return `${message.author.mention}, you need to provide an emoji of a flag to overlay!`;
|
2021-01-18 20:11:28 +00:00
|
|
|
const flag = emoji.unemojify(args[0]).replaceAll(":", "").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-07-27 00:52:13 +00:00
|
|
|
if (flag === "rainbow-flag") path = "./assets/images/rainbowflag.png";
|
|
|
|
if (flag === "checkered_flag") path = "./assets/images/checkeredflag.png";
|
|
|
|
if (flag === "🏳️⚧️") path = "./assets/images/transflag.png";
|
|
|
|
try {
|
2020-08-28 02:34:12 +00:00
|
|
|
await fs.promises.access(path);
|
2020-07-27 00:52:13 +00:00
|
|
|
} catch (e) {
|
|
|
|
return `${message.author.mention}, that isn't a flag!`;
|
|
|
|
}
|
2020-10-18 21:53:35 +00:00
|
|
|
const { buffer, type } = await magick.run({
|
2020-08-28 02:34:12 +00:00
|
|
|
cmd: "flag",
|
|
|
|
path: image.path,
|
2021-01-05 02:53:34 +00:00
|
|
|
overlay: path,
|
|
|
|
type: image.type
|
2020-08-28 02:34:12 +00:00
|
|
|
});
|
2020-06-18 19:02:35 +00:00
|
|
|
return {
|
|
|
|
file: buffer,
|
2020-10-18 21:53:35 +00:00
|
|
|
name: `flag.${type}`
|
2020-06-18 19:02:35 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.params = "[flag]";
|
|
|
|
exports.category = 5;
|
|
|
|
exports.help = "Overlays a flag onto an image";
|