Re-add a form of size limit
This commit is contained in:
parent
364d8bf006
commit
c4b57ac617
2 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue