Increase file size limit to 25MB

This commit is contained in:
Dragon Fire
2024-05-06 00:49:49 -04:00
parent fcb5896b01
commit 9460771b32
60 changed files with 63 additions and 63 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class ApprovedCommand extends Command {
const { x, y, width, height } = centerImage(base, data); const { x, y, width, height } = centerImage(base, data);
ctx.drawImage(base, x, y, width, height); ctx.drawImage(base, x, y, width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'approved.png' }] });
} }
}; };
+1 -1
View File
@@ -41,7 +41,7 @@ module.exports = class BlurCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
stackBlur.canvasRGBA(canvas, 0, 0, canvas.width, canvas.height, radius); stackBlur.canvasRGBA(canvas, 0, 0, canvas.width, canvas.height, radius);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'blur.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class BrazzersCommand extends Command {
const height = Math.round(width / ratio); const height = Math.round(width / ratio);
ctx.drawImage(base, 0, data.height - height, width, height); ctx.drawImage(base, 0, data.height - height, width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'brazzers.png' }] });
} }
}; };
+1 -1
View File
@@ -39,7 +39,7 @@ module.exports = class CharcoalCommand extends Command {
magik.charcoal(1); magik.charcoal(1);
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'charcoal.png' }] });
} }
}; };
+1 -1
View File
@@ -51,7 +51,7 @@ module.exports = class ChocolateMilkCommand extends Command {
if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0); if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(overlay, 0, 0); ctx.drawImage(overlay, 0, 0);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'chocolate-milk.png' }] });
} }
}; };
+1 -1
View File
@@ -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.drawImage(base, x + (width / 20), y + (height / 20), width * 0.9, height * 0.9);
ctx.globalAlpha = 1; ctx.globalAlpha = 1;
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'communist.png' }] });
} }
}; };
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class ContrastCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
contrast(ctx, 0, 0, data.width, data.height); contrast(ctx, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'contrast.png' }] });
} }
}; };
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = class ConvertImageCommand extends Command {
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
const attachment = canvas.toBuffer(formats[format]); 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}` }] }); return msg.say({ files: [{ attachment, name: `convert-image.${format}` }] });
} }
}; };
+1 -1
View File
@@ -36,7 +36,7 @@ module.exports = class CropToContentCommand extends Command {
return msg.say('Looks like this image is already cropped to its content.'); return msg.say('Looks like this image is already cropped to its content.');
} }
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'crop-to-content.png' }] });
} }
}; };
+1 -1
View File
@@ -39,7 +39,7 @@ module.exports = class DesaturateCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
desaturate(ctx, level, 0, 0, data.width, data.height); desaturate(ctx, level, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'desaturate.png' }] });
} }
}; };
+1 -1
View File
@@ -38,7 +38,7 @@ module.exports = class DistortCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
distort(ctx, level, 0, 0, data.width, data.height); distort(ctx, level, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'distort.png' }] });
} }
}; };
+1 -1
View File
@@ -39,7 +39,7 @@ module.exports = class EmbossCommand extends Command {
magik.emboss(); magik.emboss();
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'emboss.png' }] });
} }
}; };
+1 -1
View File
@@ -45,7 +45,7 @@ module.exports = class FireFrameCommand extends Command {
drawImageWithTint(ctx, data, '#fc671e', 0, 0, data.width, data.height); drawImageWithTint(ctx, data, '#fc671e', 0, 0, data.width, data.height);
ctx.drawImage(base, 0, 0, data.width, data.height); ctx.drawImage(base, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'fire-frame.png' }] });
} }
}; };
+1 -1
View File
@@ -48,7 +48,7 @@ module.exports = class FishEyeCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
fishEye(ctx, level, 0, 0, data.width, data.height); fishEye(ctx, level, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'fish-eye.png' }] });
} }
}; };
+1 -1
View File
@@ -63,7 +63,7 @@ module.exports = class FrameCommand extends Command {
ctx.drawImage(base, 0, 0); ctx.drawImage(base, 0, 0);
} }
const attachment = canvas.toBuffer('image/png'); 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}` }] }); return msg.say({ files: [{ attachment, name: `frame-${frame.file}` }] });
} }
}; };
+1 -1
View File
@@ -35,7 +35,7 @@ module.exports = class GhostCommand extends Command {
ctx.globalAlpha = 0.25; ctx.globalAlpha = 0.25;
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'ghost.png' }] });
} }
}; };
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = class GlassShatterCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
ctx.drawImage(base, 0, 0, data.width, data.height); ctx.drawImage(base, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'glass-shatter.png' }] });
} }
}; };
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class GlitchCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
distort(ctx, 20, 0, 0, data.width, data.height, 5); distort(ctx, 20, 0, 0, data.width, data.height, 5);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'glitch.png' }] });
} }
}; };
+1 -1
View File
@@ -35,7 +35,7 @@ module.exports = class GreyscaleCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
greyscale(ctx, 0, 0, data.width, data.height); greyscale(ctx, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'greyscale.png' }] });
} }
}; };
+1 -1
View File
@@ -45,7 +45,7 @@ module.exports = class GunCommand extends Command {
const width = base.width * ratio; const width = base.width * ratio;
ctx.drawImage(base, data.width - width, data.height - (data.height / 2), width, data.height / 2); ctx.drawImage(base, data.width - width, data.height - (data.height / 2), width, data.height / 2);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'gun.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class HandsCommand extends Command {
const height = base.height * ratio; const height = base.height * ratio;
ctx.drawImage(base, 0, data.height - height, data.width, height); ctx.drawImage(base, 0, data.height - height, data.width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'hands.png' }] });
} }
}; };
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = class IfunnyCommand extends Command {
ctx.fillRect(0, canvas.height - base.height, canvas.width, base.height); ctx.fillRect(0, canvas.height - base.height, canvas.width, base.height);
ctx.drawImage(base, canvas.width - base.width, canvas.height - base.height); ctx.drawImage(base, canvas.width - base.width, canvas.height - base.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'ifunny.png' }] });
} }
}; };
+1 -1
View File
@@ -45,7 +45,7 @@ module.exports = class ImplodeCommand extends Command {
magik.implode(level / 100); magik.implode(level / 100);
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'implode.png' }] });
} }
}; };
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class InvertCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
invert(ctx, 0, 0, data.width, data.height); invert(ctx, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'invert.png' }] });
} }
}; };
+1 -1
View File
@@ -42,7 +42,7 @@ module.exports = class LiquidRescaleCommand extends Command {
magik.implode(0.25); magik.implode(0.25);
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'liquid-rescale.png' }] });
} }
}; };
+1 -1
View File
@@ -49,7 +49,7 @@ module.exports = class MirrorCommand extends Command {
} }
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'mirror.png' }] });
} }
}; };
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class MotionBlurCommand extends Command {
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
motionBlur(ctx, data, 0, 0, data.width, data.height); motionBlur(ctx, data, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'motion-blur.png' }] });
} }
}; };
+1 -1
View File
@@ -40,7 +40,7 @@ module.exports = class NeedsMoreJpegCommand extends Command {
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
const attachment = canvas.toBuffer('image/jpeg', { quality: quality / 10 }); 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' }] }); return msg.say({ files: [{ attachment, name: 'needs-more-jpeg.jpeg' }] });
} }
}; };
+1 -1
View File
@@ -47,7 +47,7 @@ module.exports = class NoiseCommand extends Command {
magik.noise(type); magik.noise(type);
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'noise.png' }] });
} }
}; };
+1 -1
View File
@@ -40,7 +40,7 @@ module.exports = class OilPaintingCommand extends Command {
magik.paint(5); magik.paint(5);
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'old-painting.png' }] });
} }
}; };
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class PixelizeCommand extends Command {
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
pixelize(ctx, canvas, data, 0.15, 0, 0, canvas.width, canvas.height); pixelize(ctx, canvas, data, 0.15, 0, 0, canvas.width, canvas.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'pixelize.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class PoliceTapeCommand extends Command {
const { x, y, width, height } = centerImage(base, data); const { x, y, width, height } = centerImage(base, data);
ctx.drawImage(base, x, y, width, height); ctx.drawImage(base, x, y, width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'police-tape.png' }] });
} }
}; };
+1 -1
View File
@@ -36,7 +36,7 @@ module.exports = class RainbowCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
ctx.drawImage(base, 0, 0, data.width, data.height); ctx.drawImage(base, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'rainbow.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class RejctedCommand extends Command {
const { x, y, width, height } = centerImage(base, data); const { x, y, width, height } = centerImage(base, data);
ctx.drawImage(base, x, y, width, height); ctx.drawImage(base, x, y, width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'rejected.png' }] });
} }
}; };
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = class RotateCommand extends Command {
ctx.translate(canvas.width / 2, canvas.height / 2); ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.rotate(-degrees * (Math.PI / 180)); ctx.rotate(-degrees * (Math.PI / 180));
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'rotate.png' }] });
} }
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class SepiaCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
sepia(ctx, 0, 0, data.width, data.height); sepia(ctx, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'sepia.png' }] });
} }
}; };
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class SilhouetteCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
silhouette(ctx, 0, 0, data.width, data.height); silhouette(ctx, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'silhouette.png' }] });
} }
}; };
+1 -1
View File
@@ -59,7 +59,7 @@ module.exports = class SipCommand extends Command {
if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0); if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(overlay, 0, 0); ctx.drawImage(overlay, 0, 0);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'sip.png' }] });
} }
}; };
+1 -1
View File
@@ -45,7 +45,7 @@ module.exports = class SketchCommand extends Command {
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); const attachment = await magikToBuffer(magik);
await reactIfAble(msg, msg.author, SUCCESS_EMOJI_ID, '✅'); 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' }] }); return msg.say({ files: [{ attachment, name: 'sketch.png' }] });
} }
}; };
+1 -1
View File
@@ -50,7 +50,7 @@ module.exports = class SquishCommand extends Command {
magik.out(command); magik.out(command);
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'squish.png' }] });
} }
}; };
+1 -1
View File
@@ -64,7 +64,7 @@ module.exports = class SubtitleCommand extends Command {
ctx.fillText(lines[i], base.width / 2, textHeight); ctx.fillText(lines[i], base.width / 2, textHeight);
} }
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'subtitle.png' }] });
} }
}; };
+1 -1
View File
@@ -45,7 +45,7 @@ module.exports = class SwirlCommand extends Command {
magik.swirl(degrees); magik.swirl(degrees);
magik.setFormat('png'); magik.setFormat('png');
const attachment = await magikToBuffer(magik); 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' }] }); return msg.say({ files: [{ attachment, name: 'swirl.png' }] });
} }
}; };
+1 -1
View File
@@ -38,7 +38,7 @@ module.exports = class TintCommand extends Command {
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
drawImageWithTint(ctx, data, color, 0, 0, data.width, data.height); drawImageWithTint(ctx, data, color, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'tint.png' }] });
} }
}; };
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class VignetteCommand extends Command {
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
vignette(ctx, data.width, data.height); vignette(ctx, data.width, data.height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'vignette.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class YouDiedCommand extends Command {
const { x, y, width, height } = centerImage(base, data); const { x, y, width, height } = centerImage(base, data);
ctx.drawImage(base, x, y, width, height); ctx.drawImage(base, x, y, width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'you-died.png' }] });
} }
}; };
+1 -1
View File
@@ -35,7 +35,7 @@ module.exports = class DeepFryCommand extends Command {
desaturate(ctx, -20, 0, 0, data.width, data.height); desaturate(ctx, -20, 0, 0, data.width, data.height);
contrast(ctx, 0, 0, data.width, data.height); contrast(ctx, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/jpeg', { quality: 0.2 }); 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' }] }); return msg.say({ files: [{ attachment, name: 'deep-fry.jpeg' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class DislikeCommand extends Command {
ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(base, 0, 0, plate.width, height);
ctx.drawImage(plate, 0, height); ctx.drawImage(plate, 0, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'dislike.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class ForFiveHoursCommand extends Command {
ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(base, 0, 0, plate.width, height);
ctx.drawImage(plate, 0, height + 1); ctx.drawImage(plate, 0, height + 1);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'for-five-hours.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class LikeCommand extends Command {
ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(base, 0, 0, plate.width, height);
ctx.drawImage(plate, 0, height); ctx.drawImage(plate, 0, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'like.png' }] });
} }
}; };
+1 -1
View File
@@ -81,7 +81,7 @@ module.exports = class MemeGenCommand extends Command {
ctx.fillText(bottomLines[i], base.width / 2, textHeight); ctx.fillText(bottomLines[i], base.width / 2, textHeight);
} }
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'meme-gen.png' }] });
} }
}; };
+1 -1
View File
@@ -75,7 +75,7 @@ module.exports = class NikeAdCommand extends Command {
ctx.fillText(lines[i], data.width / 2, textHeight); ctx.fillText(lines[i], data.width / 2, textHeight);
} }
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'nike-ad.png' }] });
} }
}; };
+1 -1
View File
@@ -61,7 +61,7 @@ module.exports = class ReactionMemeCommand extends Command {
fillTextWithBreaks(ctx, lines.join('\n'), 5, 5); fillTextWithBreaks(ctx, lines.join('\n'), 5, 5);
ctx.drawImage(base, 0, linesLen); ctx.drawImage(base, 0, linesLen);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'meme-gen-modern.png' }] });
} }
}; };
+1 -1
View File
@@ -43,7 +43,7 @@ module.exports = class SexySinglesCommand extends Command {
ctx.drawImage(base, plate.width, 0, width, plate.height); ctx.drawImage(base, plate.width, 0, width, plate.height);
ctx.drawImage(plate, 0, 0); ctx.drawImage(plate, 0, 0);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'sexy-singles.png' }] });
} }
}; };
+1 -1
View File
@@ -65,7 +65,7 @@ module.exports = class SkyrimSkillCommand extends Command {
ctx.fillStyle = 'white'; ctx.fillStyle = 'white';
ctx.fillText(skill, 189, height + 75, 300); ctx.fillText(skill, 189, height + 75, 300);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'skyrim-skill.png' }] });
} }
}; };
+1 -1
View File
@@ -49,7 +49,7 @@ module.exports = class ThugLifeCommand extends Command {
const height = Math.round(width / ratio); const height = Math.round(width / ratio);
ctx.drawImage(base, (data.width / 2) - (width / 2), data.height - height, width, height); ctx.drawImage(base, (data.width / 2) - (width / 2), data.height - height, width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'thug-life.png' }] });
} }
}; };
+1 -1
View File
@@ -47,7 +47,7 @@ module.exports = class ToBeContinuedCommand extends Command {
const height = Math.round(width / ratio); const height = Math.round(width / ratio);
ctx.drawImage(base, 0, canvas.height - height, width, height); ctx.drawImage(base, 0, canvas.height - height, width, height);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'to-be-continued.png' }] });
} }
}; };
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = class VietnamFlashbacksCommand extends Command {
ctx.globalAlpha = 0.675; ctx.globalAlpha = 0.675;
ctx.drawImage(data, 0, 0); ctx.drawImage(data, 0, 0);
const attachment = canvas.toBuffer('image/png'); 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' }] }); return msg.say({ files: [{ attachment, name: 'vietnam-flashbacks.png' }] });
} }
}; };
+1 -1
View File
@@ -29,7 +29,7 @@ module.exports = class BunnyCommand extends Command {
let fileToSend; let fileToSend;
let fileType = 'gif'; let fileType = 'gif';
const gif = await request.get(body.media.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); const poster = await request.get(body.media.poster);
fileToSend = poster.body; fileToSend = poster.body;
fileType = 'png'; fileType = 'png';
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "150.0.0", "version": "150.1.0",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"private": true, "private": true,
+4 -4
View File
@@ -11,17 +11,17 @@ module.exports = class ImageArgument extends Argument {
async validate(value, msg) { async validate(value, msg) {
const attachment = msg.attachments.first(); const attachment = msg.attachments.first();
if (attachment) { if (attachment) {
if (attachment.size > 8e+6) return false; if (attachment.size > 8e+6) return 'Image size is above 8 MB.';
if (!fileTypeRe.test(attachment.name)) return false; if (!fileTypeRe.test(attachment.name)) return 'Provided attachment is not an image.';
return true; return true;
} }
if (fileTypeRe.test(value.toLowerCase())) { if (fileTypeRe.test(value.toLowerCase())) {
if (!validURL.isWebUri(value)) return false; if (!validURL.isWebUri(value)) return 'Provided URL is not valid.';
try { try {
await request.get(value); await request.get(value);
return true; return true;
} catch { } catch {
return false; return 'Provided URL is not valid.';
} }
} }
return false; return false;