Added flag, fixed the command count issue (for real)
This commit is contained in:
parent
49d9be8b93
commit
2f1c37579e
6 changed files with 45 additions and 1 deletions
26
commands/flag.js
Normal file
26
commands/flag.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
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-", "");
|
||||
let path = `./assets/images/country-flags/png1000px/${flag}.png`;
|
||||
if (flag === "🏴☠️") path = "./assets/images/pirateflag.png";
|
||||
console.log(flag);
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out("(", path, "-alpha", "set", "-channel", "A", "-evaluate", "multiply", "0.4", "+channel", ")").gravity("North").scale(...(size.width < size.height ? ["%[fx:u.w]", null] : [null, "%[fx:u.h]"])).out("-layers", "composite").bufferPromise(image.type, image.delay);
|
||||
return {
|
||||
file: buffer,
|
||||
name: `flag.${image.type}`
|
||||
};
|
||||
};
|
||||
|
||||
exports.params = "[flag]";
|
||||
exports.category = 5;
|
||||
exports.help = "Overlays a flag onto an image";
|
Loading…
Add table
Add a link
Reference in a new issue