Adjust not allowed formats in repost

This commit is contained in:
Dragon Fire
2021-05-01 12:29:49 -04:00
parent 9a0dc46918
commit 4b66bbd416
+4 -1
View File
@@ -5,6 +5,7 @@ const { stripIndents } = require('common-tags');
const { reactIfAble } = require('../../util/Util');
const { LOADING_EMOJI_ID, SUCCESS_EMOJI_ID, FAILURE_EMOJI_ID } = process.env;
const fileTypeRe = /\.(jpe?g|png|gif|jfif|bmp)(\?.+)?$/i;
const notAllowed = ['gif', 'jfif', 'bmp'];
module.exports = class RepostCommand extends Command {
constructor(client) {
@@ -32,7 +33,9 @@ module.exports = class RepostCommand extends Command {
}
async run(msg, { image }) {
if (image.toLowerCase().endsWith('.gif')) return msg.reply('I cannot analyze GIF images.');
if (notAllowed.includes(image.toLowerCase().match(fileTypeRe)[1])) {
return msg.reply('I cannot analyze images in this format.');
}
try {
await reactIfAble(msg, this.client.user, LOADING_EMOJI_ID, '💬');
const { body } = await request.get(image);