From 9460771b32499179209cf9d04dd1d8dfbabff888 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 6 May 2024 00:49:49 -0400 Subject: [PATCH] Increase file size limit to 25MB --- commands/edit-image/approved.js | 2 +- commands/edit-image/blur.js | 2 +- commands/edit-image/brazzers.js | 2 +- commands/edit-image/charcoal.js | 2 +- commands/edit-image/chocolate-milk.js | 2 +- commands/edit-image/communist.js | 2 +- commands/edit-image/contrast.js | 2 +- commands/edit-image/convert-image.js | 2 +- commands/edit-image/crop-to-content.js | 2 +- commands/edit-image/desaturate.js | 2 +- commands/edit-image/distort.js | 2 +- commands/edit-image/emboss.js | 2 +- commands/edit-image/fire-frame.js | 2 +- commands/edit-image/fish-eye.js | 2 +- commands/edit-image/frame.js | 2 +- commands/edit-image/ghost.js | 2 +- commands/edit-image/glass-shatter.js | 2 +- commands/edit-image/glitch.js | 2 +- commands/edit-image/greyscale.js | 2 +- commands/edit-image/gun.js | 2 +- commands/edit-image/hands.js | 2 +- commands/edit-image/ifunny.js | 2 +- commands/edit-image/implode.js | 2 +- commands/edit-image/invert.js | 2 +- commands/edit-image/liquid-rescale.js | 2 +- commands/edit-image/mirror.js | 2 +- commands/edit-image/motion-blur.js | 2 +- commands/edit-image/needs-more-jpeg.js | 2 +- commands/edit-image/noise.js | 2 +- commands/edit-image/oil-painting.js | 2 +- commands/edit-image/pixelize.js | 2 +- commands/edit-image/police-tape.js | 2 +- commands/edit-image/rainbow.js | 2 +- commands/edit-image/rejected.js | 2 +- commands/edit-image/rotate.js | 2 +- commands/edit-image/sepia.js | 2 +- commands/edit-image/silhouette.js | 2 +- commands/edit-image/sip.js | 2 +- commands/edit-image/sketch.js | 2 +- commands/edit-image/squish.js | 2 +- commands/edit-image/subtitle.js | 2 +- commands/edit-image/swirl.js | 2 +- commands/edit-image/tint.js | 2 +- commands/edit-image/vignette.js | 2 +- commands/edit-image/you-died.js | 2 +- commands/edit-meme/deep-fry.js | 2 +- commands/edit-meme/dislike.js | 2 +- commands/edit-meme/for-five-hours.js | 2 +- commands/edit-meme/like.js | 2 +- commands/edit-meme/meme-gen.js | 2 +- commands/edit-meme/nike-ad.js | 2 +- commands/edit-meme/reaction-meme.js | 2 +- commands/edit-meme/sexy-singles.js | 2 +- commands/edit-meme/skyrim-skill.js | 2 +- commands/edit-meme/thug-life.js | 2 +- commands/edit-meme/to-be-continued.js | 2 +- commands/edit-meme/vietnam-flashbacks.js | 2 +- commands/random-img/bunny.js | 2 +- package.json | 2 +- types/image.js | 8 ++++---- 60 files changed, 63 insertions(+), 63 deletions(-) diff --git a/commands/edit-image/approved.js b/commands/edit-image/approved.js index 035e4eaf..918255d5 100644 --- a/commands/edit-image/approved.js +++ b/commands/edit-image/approved.js @@ -46,7 +46,7 @@ module.exports = class ApprovedCommand extends Command { const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'approved.png' }] }); } }; diff --git a/commands/edit-image/blur.js b/commands/edit-image/blur.js index f6bbf095..1778703d 100644 --- a/commands/edit-image/blur.js +++ b/commands/edit-image/blur.js @@ -41,7 +41,7 @@ module.exports = class BlurCommand extends Command { ctx.drawImage(data, 0, 0); stackBlur.canvasRGBA(canvas, 0, 0, canvas.width, canvas.height, radius); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'blur.png' }] }); } }; diff --git a/commands/edit-image/brazzers.js b/commands/edit-image/brazzers.js index 862ad909..1d49438c 100644 --- a/commands/edit-image/brazzers.js +++ b/commands/edit-image/brazzers.js @@ -46,7 +46,7 @@ module.exports = class BrazzersCommand extends Command { const height = Math.round(width / ratio); ctx.drawImage(base, 0, data.height - height, width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'brazzers.png' }] }); } }; diff --git a/commands/edit-image/charcoal.js b/commands/edit-image/charcoal.js index e885dfe7..1929f8e6 100644 --- a/commands/edit-image/charcoal.js +++ b/commands/edit-image/charcoal.js @@ -39,7 +39,7 @@ module.exports = class CharcoalCommand extends Command { magik.charcoal(1); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'charcoal.png' }] }); } }; diff --git a/commands/edit-image/chocolate-milk.js b/commands/edit-image/chocolate-milk.js index f6881681..c834d1ce 100644 --- a/commands/edit-image/chocolate-milk.js +++ b/commands/edit-image/chocolate-milk.js @@ -51,7 +51,7 @@ module.exports = class ChocolateMilkCommand extends Command { if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(overlay, 0, 0); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'chocolate-milk.png' }] }); } }; diff --git a/commands/edit-image/communist.js b/commands/edit-image/communist.js index a448de68..35a093cf 100644 --- a/commands/edit-image/communist.js +++ b/commands/edit-image/communist.js @@ -48,7 +48,7 @@ module.exports = class CommunistCommand extends Command { ctx.drawImage(base, x + (width / 20), y + (height / 20), width * 0.9, height * 0.9); ctx.globalAlpha = 1; const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'communist.png' }] }); } }; diff --git a/commands/edit-image/contrast.js b/commands/edit-image/contrast.js index a7550b01..2668c2f3 100644 --- a/commands/edit-image/contrast.js +++ b/commands/edit-image/contrast.js @@ -34,7 +34,7 @@ module.exports = class ContrastCommand extends Command { ctx.drawImage(data, 0, 0); contrast(ctx, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'contrast.png' }] }); } }; diff --git a/commands/edit-image/convert-image.js b/commands/edit-image/convert-image.js index 834f2c45..01d16db7 100644 --- a/commands/edit-image/convert-image.js +++ b/commands/edit-image/convert-image.js @@ -44,7 +44,7 @@ module.exports = class ConvertImageCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); const attachment = canvas.toBuffer(formats[format]); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: `convert-image.${format}` }] }); } }; diff --git a/commands/edit-image/crop-to-content.js b/commands/edit-image/crop-to-content.js index 765ee93a..58ddacf6 100644 --- a/commands/edit-image/crop-to-content.js +++ b/commands/edit-image/crop-to-content.js @@ -36,7 +36,7 @@ module.exports = class CropToContentCommand extends Command { return msg.say('Looks like this image is already cropped to its content.'); } const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'crop-to-content.png' }] }); } }; diff --git a/commands/edit-image/desaturate.js b/commands/edit-image/desaturate.js index 56f62fa9..d40e9d22 100644 --- a/commands/edit-image/desaturate.js +++ b/commands/edit-image/desaturate.js @@ -39,7 +39,7 @@ module.exports = class DesaturateCommand extends Command { ctx.drawImage(data, 0, 0); desaturate(ctx, level, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'desaturate.png' }] }); } }; diff --git a/commands/edit-image/distort.js b/commands/edit-image/distort.js index b4291132..5c0329b6 100644 --- a/commands/edit-image/distort.js +++ b/commands/edit-image/distort.js @@ -38,7 +38,7 @@ module.exports = class DistortCommand extends Command { ctx.drawImage(data, 0, 0); distort(ctx, level, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'distort.png' }] }); } }; diff --git a/commands/edit-image/emboss.js b/commands/edit-image/emboss.js index 01982f55..444b9ef8 100644 --- a/commands/edit-image/emboss.js +++ b/commands/edit-image/emboss.js @@ -39,7 +39,7 @@ module.exports = class EmbossCommand extends Command { magik.emboss(); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'emboss.png' }] }); } }; diff --git a/commands/edit-image/fire-frame.js b/commands/edit-image/fire-frame.js index 9a8d21fa..9e2dcaa4 100644 --- a/commands/edit-image/fire-frame.js +++ b/commands/edit-image/fire-frame.js @@ -45,7 +45,7 @@ module.exports = class FireFrameCommand extends Command { drawImageWithTint(ctx, data, '#fc671e', 0, 0, data.width, data.height); ctx.drawImage(base, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'fire-frame.png' }] }); } }; diff --git a/commands/edit-image/fish-eye.js b/commands/edit-image/fish-eye.js index 948c5574..77196d36 100644 --- a/commands/edit-image/fish-eye.js +++ b/commands/edit-image/fish-eye.js @@ -48,7 +48,7 @@ module.exports = class FishEyeCommand extends Command { ctx.drawImage(data, 0, 0); fishEye(ctx, level, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'fish-eye.png' }] }); } }; diff --git a/commands/edit-image/frame.js b/commands/edit-image/frame.js index 54361d87..52a99cba 100644 --- a/commands/edit-image/frame.js +++ b/commands/edit-image/frame.js @@ -63,7 +63,7 @@ module.exports = class FrameCommand extends Command { ctx.drawImage(base, 0, 0); } const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: `frame-${frame.file}` }] }); } }; diff --git a/commands/edit-image/ghost.js b/commands/edit-image/ghost.js index df196fb4..dbbbfd58 100644 --- a/commands/edit-image/ghost.js +++ b/commands/edit-image/ghost.js @@ -35,7 +35,7 @@ module.exports = class GhostCommand extends Command { ctx.globalAlpha = 0.25; ctx.drawImage(data, 0, 0); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'ghost.png' }] }); } }; diff --git a/commands/edit-image/glass-shatter.js b/commands/edit-image/glass-shatter.js index 5dac6a0a..afb18550 100644 --- a/commands/edit-image/glass-shatter.js +++ b/commands/edit-image/glass-shatter.js @@ -44,7 +44,7 @@ module.exports = class GlassShatterCommand extends Command { ctx.drawImage(data, 0, 0); ctx.drawImage(base, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'glass-shatter.png' }] }); } }; diff --git a/commands/edit-image/glitch.js b/commands/edit-image/glitch.js index 9a7c76af..7b5f755c 100644 --- a/commands/edit-image/glitch.js +++ b/commands/edit-image/glitch.js @@ -34,7 +34,7 @@ module.exports = class GlitchCommand extends Command { ctx.drawImage(data, 0, 0); distort(ctx, 20, 0, 0, data.width, data.height, 5); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'glitch.png' }] }); } }; diff --git a/commands/edit-image/greyscale.js b/commands/edit-image/greyscale.js index 02cb0f3d..b8ce1178 100644 --- a/commands/edit-image/greyscale.js +++ b/commands/edit-image/greyscale.js @@ -35,7 +35,7 @@ module.exports = class GreyscaleCommand extends Command { ctx.drawImage(data, 0, 0); greyscale(ctx, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'greyscale.png' }] }); } }; diff --git a/commands/edit-image/gun.js b/commands/edit-image/gun.js index 7969ece7..b8d33670 100644 --- a/commands/edit-image/gun.js +++ b/commands/edit-image/gun.js @@ -45,7 +45,7 @@ module.exports = class GunCommand extends Command { const width = base.width * ratio; ctx.drawImage(base, data.width - width, data.height - (data.height / 2), width, data.height / 2); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'gun.png' }] }); } }; diff --git a/commands/edit-image/hands.js b/commands/edit-image/hands.js index 7345bbd6..67edd5f9 100644 --- a/commands/edit-image/hands.js +++ b/commands/edit-image/hands.js @@ -46,7 +46,7 @@ module.exports = class HandsCommand extends Command { const height = base.height * ratio; ctx.drawImage(base, 0, data.height - height, data.width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'hands.png' }] }); } }; diff --git a/commands/edit-image/ifunny.js b/commands/edit-image/ifunny.js index ddaa83ca..607fe215 100644 --- a/commands/edit-image/ifunny.js +++ b/commands/edit-image/ifunny.js @@ -44,7 +44,7 @@ module.exports = class IfunnyCommand extends Command { ctx.fillRect(0, canvas.height - base.height, canvas.width, base.height); ctx.drawImage(base, canvas.width - base.width, canvas.height - base.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'ifunny.png' }] }); } }; diff --git a/commands/edit-image/implode.js b/commands/edit-image/implode.js index cf248abd..5ad531b0 100644 --- a/commands/edit-image/implode.js +++ b/commands/edit-image/implode.js @@ -45,7 +45,7 @@ module.exports = class ImplodeCommand extends Command { magik.implode(level / 100); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'implode.png' }] }); } }; diff --git a/commands/edit-image/invert.js b/commands/edit-image/invert.js index 5a1eac4c..3722f024 100644 --- a/commands/edit-image/invert.js +++ b/commands/edit-image/invert.js @@ -34,7 +34,7 @@ module.exports = class InvertCommand extends Command { ctx.drawImage(data, 0, 0); invert(ctx, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'invert.png' }] }); } }; diff --git a/commands/edit-image/liquid-rescale.js b/commands/edit-image/liquid-rescale.js index ac57cdac..1a47d350 100644 --- a/commands/edit-image/liquid-rescale.js +++ b/commands/edit-image/liquid-rescale.js @@ -42,7 +42,7 @@ module.exports = class LiquidRescaleCommand extends Command { magik.implode(0.25); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'liquid-rescale.png' }] }); } }; diff --git a/commands/edit-image/mirror.js b/commands/edit-image/mirror.js index c36e38ee..38d518a7 100644 --- a/commands/edit-image/mirror.js +++ b/commands/edit-image/mirror.js @@ -49,7 +49,7 @@ module.exports = class MirrorCommand extends Command { } ctx.drawImage(data, 0, 0); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'mirror.png' }] }); } }; diff --git a/commands/edit-image/motion-blur.js b/commands/edit-image/motion-blur.js index 6060af6d..e2e6f168 100644 --- a/commands/edit-image/motion-blur.js +++ b/commands/edit-image/motion-blur.js @@ -34,7 +34,7 @@ module.exports = class MotionBlurCommand extends Command { const ctx = canvas.getContext('2d'); motionBlur(ctx, data, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'motion-blur.png' }] }); } }; diff --git a/commands/edit-image/needs-more-jpeg.js b/commands/edit-image/needs-more-jpeg.js index 883677bc..87f5ff1f 100644 --- a/commands/edit-image/needs-more-jpeg.js +++ b/commands/edit-image/needs-more-jpeg.js @@ -40,7 +40,7 @@ module.exports = class NeedsMoreJpegCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); const attachment = canvas.toBuffer('image/jpeg', { quality: quality / 10 }); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'needs-more-jpeg.jpeg' }] }); } }; diff --git a/commands/edit-image/noise.js b/commands/edit-image/noise.js index f76308d7..15cb33e6 100644 --- a/commands/edit-image/noise.js +++ b/commands/edit-image/noise.js @@ -47,7 +47,7 @@ module.exports = class NoiseCommand extends Command { magik.noise(type); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'noise.png' }] }); } }; diff --git a/commands/edit-image/oil-painting.js b/commands/edit-image/oil-painting.js index c72da9cf..8ab714f3 100644 --- a/commands/edit-image/oil-painting.js +++ b/commands/edit-image/oil-painting.js @@ -40,7 +40,7 @@ module.exports = class OilPaintingCommand extends Command { magik.paint(5); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'old-painting.png' }] }); } }; diff --git a/commands/edit-image/pixelize.js b/commands/edit-image/pixelize.js index 5c1ee8b2..120a28c1 100644 --- a/commands/edit-image/pixelize.js +++ b/commands/edit-image/pixelize.js @@ -34,7 +34,7 @@ module.exports = class PixelizeCommand extends Command { const ctx = canvas.getContext('2d'); pixelize(ctx, canvas, data, 0.15, 0, 0, canvas.width, canvas.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'pixelize.png' }] }); } }; diff --git a/commands/edit-image/police-tape.js b/commands/edit-image/police-tape.js index 303c0058..06f125e6 100644 --- a/commands/edit-image/police-tape.js +++ b/commands/edit-image/police-tape.js @@ -46,7 +46,7 @@ module.exports = class PoliceTapeCommand extends Command { const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'police-tape.png' }] }); } }; diff --git a/commands/edit-image/rainbow.js b/commands/edit-image/rainbow.js index ba627eb7..56aa2b9a 100644 --- a/commands/edit-image/rainbow.js +++ b/commands/edit-image/rainbow.js @@ -36,7 +36,7 @@ module.exports = class RainbowCommand extends Command { ctx.drawImage(data, 0, 0); ctx.drawImage(base, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'rainbow.png' }] }); } }; diff --git a/commands/edit-image/rejected.js b/commands/edit-image/rejected.js index 6667be58..32abf572 100644 --- a/commands/edit-image/rejected.js +++ b/commands/edit-image/rejected.js @@ -46,7 +46,7 @@ module.exports = class RejctedCommand extends Command { const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'rejected.png' }] }); } }; diff --git a/commands/edit-image/rotate.js b/commands/edit-image/rotate.js index bd09b735..3cb7d5b0 100644 --- a/commands/edit-image/rotate.js +++ b/commands/edit-image/rotate.js @@ -44,7 +44,7 @@ module.exports = class RotateCommand extends Command { ctx.translate(canvas.width / 2, canvas.height / 2); ctx.rotate(-degrees * (Math.PI / 180)); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'rotate.png' }] }); } diff --git a/commands/edit-image/sepia.js b/commands/edit-image/sepia.js index 81dc4de7..7a976b78 100644 --- a/commands/edit-image/sepia.js +++ b/commands/edit-image/sepia.js @@ -34,7 +34,7 @@ module.exports = class SepiaCommand extends Command { ctx.drawImage(data, 0, 0); sepia(ctx, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'sepia.png' }] }); } }; diff --git a/commands/edit-image/silhouette.js b/commands/edit-image/silhouette.js index 5b4cb553..76e5a7fd 100644 --- a/commands/edit-image/silhouette.js +++ b/commands/edit-image/silhouette.js @@ -34,7 +34,7 @@ module.exports = class SilhouetteCommand extends Command { ctx.drawImage(data, 0, 0); silhouette(ctx, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'silhouette.png' }] }); } }; diff --git a/commands/edit-image/sip.js b/commands/edit-image/sip.js index 75a1de67..021ade8b 100644 --- a/commands/edit-image/sip.js +++ b/commands/edit-image/sip.js @@ -59,7 +59,7 @@ module.exports = class SipCommand extends Command { if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(overlay, 0, 0); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'sip.png' }] }); } }; diff --git a/commands/edit-image/sketch.js b/commands/edit-image/sketch.js index 5060a413..f37190ab 100644 --- a/commands/edit-image/sketch.js +++ b/commands/edit-image/sketch.js @@ -45,7 +45,7 @@ module.exports = class SketchCommand extends Command { magik.setFormat('png'); const attachment = await magikToBuffer(magik); await reactIfAble(msg, msg.author, SUCCESS_EMOJI_ID, '✅'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'sketch.png' }] }); } }; diff --git a/commands/edit-image/squish.js b/commands/edit-image/squish.js index db07b8f4..29bb87c0 100644 --- a/commands/edit-image/squish.js +++ b/commands/edit-image/squish.js @@ -50,7 +50,7 @@ module.exports = class SquishCommand extends Command { magik.out(command); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'squish.png' }] }); } }; diff --git a/commands/edit-image/subtitle.js b/commands/edit-image/subtitle.js index cee4c847..87094623 100644 --- a/commands/edit-image/subtitle.js +++ b/commands/edit-image/subtitle.js @@ -64,7 +64,7 @@ module.exports = class SubtitleCommand extends Command { ctx.fillText(lines[i], base.width / 2, textHeight); } const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'subtitle.png' }] }); } }; diff --git a/commands/edit-image/swirl.js b/commands/edit-image/swirl.js index 423b8770..de076976 100644 --- a/commands/edit-image/swirl.js +++ b/commands/edit-image/swirl.js @@ -45,7 +45,7 @@ module.exports = class SwirlCommand extends Command { magik.swirl(degrees); magik.setFormat('png'); const attachment = await magikToBuffer(magik); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'swirl.png' }] }); } }; diff --git a/commands/edit-image/tint.js b/commands/edit-image/tint.js index 56fc2481..8a22644f 100644 --- a/commands/edit-image/tint.js +++ b/commands/edit-image/tint.js @@ -38,7 +38,7 @@ module.exports = class TintCommand extends Command { const ctx = canvas.getContext('2d'); drawImageWithTint(ctx, data, color, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'tint.png' }] }); } }; diff --git a/commands/edit-image/vignette.js b/commands/edit-image/vignette.js index 52d50ec6..9cac185e 100644 --- a/commands/edit-image/vignette.js +++ b/commands/edit-image/vignette.js @@ -34,7 +34,7 @@ module.exports = class VignetteCommand extends Command { ctx.drawImage(data, 0, 0); vignette(ctx, data.width, data.height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'vignette.png' }] }); } }; diff --git a/commands/edit-image/you-died.js b/commands/edit-image/you-died.js index a93a3c70..2f7e25ca 100644 --- a/commands/edit-image/you-died.js +++ b/commands/edit-image/you-died.js @@ -46,7 +46,7 @@ module.exports = class YouDiedCommand extends Command { const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'you-died.png' }] }); } }; diff --git a/commands/edit-meme/deep-fry.js b/commands/edit-meme/deep-fry.js index 0804d5a6..4d7dc927 100644 --- a/commands/edit-meme/deep-fry.js +++ b/commands/edit-meme/deep-fry.js @@ -35,7 +35,7 @@ module.exports = class DeepFryCommand extends Command { desaturate(ctx, -20, 0, 0, data.width, data.height); contrast(ctx, 0, 0, data.width, data.height); const attachment = canvas.toBuffer('image/jpeg', { quality: 0.2 }); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'deep-fry.jpeg' }] }); } }; diff --git a/commands/edit-meme/dislike.js b/commands/edit-meme/dislike.js index 85a81bde..6295bae5 100644 --- a/commands/edit-meme/dislike.js +++ b/commands/edit-meme/dislike.js @@ -46,7 +46,7 @@ module.exports = class DislikeCommand extends Command { ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'dislike.png' }] }); } }; diff --git a/commands/edit-meme/for-five-hours.js b/commands/edit-meme/for-five-hours.js index 5f0ac5f8..7f1f0aa2 100644 --- a/commands/edit-meme/for-five-hours.js +++ b/commands/edit-meme/for-five-hours.js @@ -46,7 +46,7 @@ module.exports = class ForFiveHoursCommand extends Command { ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height + 1); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'for-five-hours.png' }] }); } }; diff --git a/commands/edit-meme/like.js b/commands/edit-meme/like.js index f51c7d1b..743c5f06 100644 --- a/commands/edit-meme/like.js +++ b/commands/edit-meme/like.js @@ -46,7 +46,7 @@ module.exports = class LikeCommand extends Command { ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'like.png' }] }); } }; diff --git a/commands/edit-meme/meme-gen.js b/commands/edit-meme/meme-gen.js index 6c044556..d983292d 100644 --- a/commands/edit-meme/meme-gen.js +++ b/commands/edit-meme/meme-gen.js @@ -81,7 +81,7 @@ module.exports = class MemeGenCommand extends Command { ctx.fillText(bottomLines[i], base.width / 2, textHeight); } const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'meme-gen.png' }] }); } }; diff --git a/commands/edit-meme/nike-ad.js b/commands/edit-meme/nike-ad.js index 8f03fd03..478e2d45 100644 --- a/commands/edit-meme/nike-ad.js +++ b/commands/edit-meme/nike-ad.js @@ -75,7 +75,7 @@ module.exports = class NikeAdCommand extends Command { ctx.fillText(lines[i], data.width / 2, textHeight); } const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'nike-ad.png' }] }); } }; diff --git a/commands/edit-meme/reaction-meme.js b/commands/edit-meme/reaction-meme.js index 3bec05fa..b23458ba 100644 --- a/commands/edit-meme/reaction-meme.js +++ b/commands/edit-meme/reaction-meme.js @@ -61,7 +61,7 @@ module.exports = class ReactionMemeCommand extends Command { fillTextWithBreaks(ctx, lines.join('\n'), 5, 5); ctx.drawImage(base, 0, linesLen); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'meme-gen-modern.png' }] }); } }; diff --git a/commands/edit-meme/sexy-singles.js b/commands/edit-meme/sexy-singles.js index 76dcf555..0093fc32 100644 --- a/commands/edit-meme/sexy-singles.js +++ b/commands/edit-meme/sexy-singles.js @@ -43,7 +43,7 @@ module.exports = class SexySinglesCommand extends Command { ctx.drawImage(base, plate.width, 0, width, plate.height); ctx.drawImage(plate, 0, 0); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'sexy-singles.png' }] }); } }; diff --git a/commands/edit-meme/skyrim-skill.js b/commands/edit-meme/skyrim-skill.js index c6a66134..10487654 100644 --- a/commands/edit-meme/skyrim-skill.js +++ b/commands/edit-meme/skyrim-skill.js @@ -65,7 +65,7 @@ module.exports = class SkyrimSkillCommand extends Command { ctx.fillStyle = 'white'; ctx.fillText(skill, 189, height + 75, 300); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'skyrim-skill.png' }] }); } }; diff --git a/commands/edit-meme/thug-life.js b/commands/edit-meme/thug-life.js index afaf05f1..8ac0bfe6 100644 --- a/commands/edit-meme/thug-life.js +++ b/commands/edit-meme/thug-life.js @@ -49,7 +49,7 @@ module.exports = class ThugLifeCommand extends Command { const height = Math.round(width / ratio); ctx.drawImage(base, (data.width / 2) - (width / 2), data.height - height, width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'thug-life.png' }] }); } }; diff --git a/commands/edit-meme/to-be-continued.js b/commands/edit-meme/to-be-continued.js index 802aa484..9e1157dd 100644 --- a/commands/edit-meme/to-be-continued.js +++ b/commands/edit-meme/to-be-continued.js @@ -47,7 +47,7 @@ module.exports = class ToBeContinuedCommand extends Command { const height = Math.round(width / ratio); ctx.drawImage(base, 0, canvas.height - height, width, height); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'to-be-continued.png' }] }); } }; diff --git a/commands/edit-meme/vietnam-flashbacks.js b/commands/edit-meme/vietnam-flashbacks.js index 6ff4ac2f..e597af6a 100644 --- a/commands/edit-meme/vietnam-flashbacks.js +++ b/commands/edit-meme/vietnam-flashbacks.js @@ -46,7 +46,7 @@ module.exports = class VietnamFlashbacksCommand extends Command { ctx.globalAlpha = 0.675; ctx.drawImage(data, 0, 0); const attachment = canvas.toBuffer('image/png'); - if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); return msg.say({ files: [{ attachment, name: 'vietnam-flashbacks.png' }] }); } }; diff --git a/commands/random-img/bunny.js b/commands/random-img/bunny.js index d23bbd90..25afa4cb 100644 --- a/commands/random-img/bunny.js +++ b/commands/random-img/bunny.js @@ -29,7 +29,7 @@ module.exports = class BunnyCommand extends Command { let fileToSend; let fileType = 'gif'; const gif = await request.get(body.media.gif); - if (Buffer.byteLength(gif.body) > 8e+6) { + if (Buffer.byteLength(gif.body) > 2.5e+7) { const poster = await request.get(body.media.poster); fileToSend = poster.body; fileType = 'png'; diff --git a/package.json b/package.json index 6536b287..0356e4b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "150.0.0", + "version": "150.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "private": true, diff --git a/types/image.js b/types/image.js index ab1c844f..e048edac 100644 --- a/types/image.js +++ b/types/image.js @@ -11,17 +11,17 @@ module.exports = class ImageArgument extends Argument { async validate(value, msg) { const attachment = msg.attachments.first(); if (attachment) { - if (attachment.size > 8e+6) return false; - if (!fileTypeRe.test(attachment.name)) return false; + if (attachment.size > 8e+6) return 'Image size is above 8 MB.'; + if (!fileTypeRe.test(attachment.name)) return 'Provided attachment is not an image.'; return true; } if (fileTypeRe.test(value.toLowerCase())) { - if (!validURL.isWebUri(value)) return false; + if (!validURL.isWebUri(value)) return 'Provided URL is not valid.'; try { await request.get(value); return true; } catch { - return false; + return 'Provided URL is not valid.'; } } return false;