mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
Face Analyze, Analyze group
This commit is contained in:
@@ -34,7 +34,9 @@ module.exports = class ContrastCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
contrast(ctx, 0, 0, data.width, data.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'contrast.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'contrast.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ module.exports = class DistortCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
distort(ctx, level, 0, 0, data.width, data.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'distort.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'distort.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ module.exports = class GlitchCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
distort(ctx, 20, 0, 0, data.width, data.height, 5);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'glitch.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'glitch.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ module.exports = class GreyscaleCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
greyscale(ctx, 0, 0, data.width, data.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'greyscale.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'greyscale.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ module.exports = class IfunnyCommand extends Command {
|
||||
ctx.fillStyle = '#181619';
|
||||
ctx.fillRect(0, canvas.height - base.height, canvas.width, base.height);
|
||||
ctx.drawImage(base, canvas.width - base.width, canvas.height - base.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ifunny.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'ifunny.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ module.exports = class InvertCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
invert(ctx, 0, 0, data.width, data.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'invert.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'invert.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ module.exports = class SepiaCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
sepia(ctx, 0, 0, data.width, data.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'sepia.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'sepia.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ module.exports = class SilhouetteCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
silhouette(ctx, 0, 0, data.width, data.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'silhouette.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'silhouette.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,9 @@ module.exports = class TintCommand extends Command {
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
drawImageWithTint(ctx, data, color, 0, 0, data.width, data.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'tint.png' }] });
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'tint.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user