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
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "assets/images/country-flags"]
|
||||||
|
path = assets/images/country-flags
|
||||||
|
url = https://github.com/hjnilsson/country-flags.git
|
BIN
assets/images/pirateflag.png
Normal file
BIN
assets/images/pirateflag.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
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";
|
|
@ -40,7 +40,8 @@ module.exports = async (message) => {
|
||||||
logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`);
|
logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`);
|
||||||
try {
|
try {
|
||||||
const global = (await database.global.findOne({}).exec());
|
const global = (await database.global.findOne({}).exec());
|
||||||
global.cmdCounts.set(collections.aliases.has(command) ? collections.aliases.get(command) : command, ((isNaN(global.cmdCounts.get(command)) ? 0 : parseFloat(global.cmdCounts.get(command))) + 1).toFixed());
|
const count = global.cmdCounts.get(collections.aliases.has(command) ? collections.aliases.get(command) : command);
|
||||||
|
global.cmdCounts.set(collections.aliases.has(command) ? collections.aliases.get(command) : command, parseInt(count) + 1);
|
||||||
await global.save();
|
await global.save();
|
||||||
const result = await cmd(message, args, content.replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy
|
const result = await cmd(message, args, content.replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy
|
||||||
if (typeof result === "string" || (typeof result === "object" && result.embed)) {
|
if (typeof result === "string" || (typeof result === "object" && result.embed)) {
|
||||||
|
|
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -1462,6 +1462,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
|
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
|
||||||
},
|
},
|
||||||
|
"lodash.toarray": {
|
||||||
|
"version": "4.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz",
|
||||||
|
"integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE="
|
||||||
|
},
|
||||||
"logform": {
|
"logform": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/logform/-/logform-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/logform/-/logform-2.1.2.tgz",
|
||||||
|
@ -1711,6 +1716,14 @@
|
||||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz",
|
||||||
"integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg=="
|
"integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg=="
|
||||||
},
|
},
|
||||||
|
"node-emoji": {
|
||||||
|
"version": "1.10.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz",
|
||||||
|
"integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==",
|
||||||
|
"requires": {
|
||||||
|
"lodash.toarray": "^4.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.0",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"moment": "^2.26.0",
|
"moment": "^2.26.0",
|
||||||
"moment-duration-format": "^2.3.2",
|
"moment-duration-format": "^2.3.2",
|
||||||
"mongoose": "^5.9.19",
|
"mongoose": "^5.9.19",
|
||||||
|
"node-emoji": "^1.10.0",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"node-tweet": "^0.1.4",
|
"node-tweet": "^0.1.4",
|
||||||
"puppeteer-core": "^2.1.1",
|
"puppeteer-core": "^2.1.1",
|
||||||
|
|
Loading…
Reference in a new issue