Fix flag command erroring when no flag provided (#67)

This commit is contained in:
adroitwhiz 2021-02-25 16:10:03 -05:00 committed by GitHub
parent 4842479001
commit dabf02eb5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,7 @@ exports.run = async (message, args) => {
message.channel.sendTyping(); message.channel.sendTyping();
const image = await require("../utils/imagedetect.js")(message); 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 (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!`; if (args.length === 0 || !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]).replaceAll(":", "").replace("flag-", ""); const flag = emoji.unemojify(args[0]).replaceAll(":", "").replace("flag-", "");
let path = `./assets/images/region-flags/png/${flag.toUpperCase()}.png`; let path = `./assets/images/region-flags/png/${flag.toUpperCase()}.png`;
if (flag === "🏴‍☠️") path = "./assets/images/pirateflag.png"; if (flag === "🏴‍☠️") path = "./assets/images/pirateflag.png";