mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Increase file size limit to 25MB
This commit is contained in:
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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}` }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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}` }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "150.0.0",
|
||||
"version": "150.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"private": true,
|
||||
|
||||
+4
-4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user