diff --git a/classes/imageCommand.js b/classes/imageCommand.js index 037c410..922858a 100644 --- a/classes/imageCommand.js +++ b/classes/imageCommand.js @@ -57,6 +57,10 @@ class ImageCommand extends Command { collections.runningCommands.delete(this.message.author.id); return this.constructor.noImage; } + if (image.type === "large") { + collections.runningCommands.delete(this.message.author.id); + return `${this.message.author.mention}, that image is too large!`; + } magickParams.path = image.path; magickParams.type = image.type; magickParams.url = image.url; // technically not required but can be useful for text filtering diff --git a/utils/image.js b/utils/image.js index fdfe4cc..a1df472 100644 --- a/utils/image.js +++ b/utils/image.js @@ -210,6 +210,10 @@ exports.getType = async (image) => { "Range": "bytes=0-1023" }}); clearTimeout(timeout); + if (parseInt(imageRequest.headers.get("Content-Range").split("/")[1]) > 20971520) { + type = "large"; + return type; + } const imageBuffer = await imageRequest.buffer(); const imageType = await fileType.fromBuffer(imageBuffer); if (imageType && formats.includes(imageType.mime)) {