From 4b66bbd41612a3bac67a2020f96df0265b369ced Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 1 May 2021 12:29:49 -0400 Subject: [PATCH] Adjust not allowed formats in repost --- commands/analyze/repost.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/analyze/repost.js b/commands/analyze/repost.js index 52e91bb0..0b422e40 100644 --- a/commands/analyze/repost.js +++ b/commands/analyze/repost.js @@ -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);