diff --git a/commands/edit-image/sketch.js b/commands/edit-image/sketch.js index f9c9359b..c8d5820b 100644 --- a/commands/edit-image/sketch.js +++ b/commands/edit-image/sketch.js @@ -16,9 +16,10 @@ module.exports = class SketchCommand extends Command { description: 'Draws an image or a user\'s avatar but sketched.', throttling: { usages: 1, - duration: 60 + duration: 120 }, clientPermissions: [PermissionFlagsBits.AttachFiles], + maxAttachmentSize: 2e+6, args: [ { key: 'image', diff --git a/framework/Argument.js b/framework/Argument.js index 4fb30146..76f380e3 100644 --- a/framework/Argument.js +++ b/framework/Argument.js @@ -11,6 +11,7 @@ module.exports = class Argument { this.min = typeof options.min === 'undefined' ? null : options.min; this.max = typeof options.max === 'undefined' ? null : options.max; this.oneOf = typeof options.oneOf === 'undefined' ? null : options.oneOf; + this.maxAttachmentSize = typeof options.maxAttachmentSize === 'undefined' ? null : options.maxAttachmentSize; this.default = typeof options.default === 'undefined' ? null : options.default; this.infinite = options.infinite || false; this.avatarSize = options.avatarSize || 2048; diff --git a/types/image.js b/types/image.js index e048edac..f46f961d 100644 --- a/types/image.js +++ b/types/image.js @@ -8,10 +8,13 @@ module.exports = class ImageArgument extends Argument { super(client, 'image'); } - async validate(value, msg) { + async validate(value, msg, arg) { const attachment = msg.attachments.first(); if (attachment) { - if (attachment.size > 8e+6) return 'Image size is above 8 MB.'; + if (attachment.size > arg.maxAttachmentSize) { + const displaySize = Math.floor(arg.maxAttachmentSize / 1000000); + return `Image size is above ${displaySize} MB.`; + } if (!fileTypeRe.test(attachment.name)) return 'Provided attachment is not an image.'; return true; }