Begin migrating away from stupid "Oh no, an error occurred!"

This commit is contained in:
Dragon Fire
2024-03-29 23:57:49 -04:00
parent 067545b818
commit 0b807767d1
130 changed files with 1692 additions and 2190 deletions
+17 -21
View File
@@ -37,26 +37,22 @@ module.exports = class WorthlessCommand extends Command {
}
async run(msg, { image }) {
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'worthless.png'));
const { body } = await request.get(image);
const data = await loadImage(body);
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.rotate(6 * (Math.PI / 180));
const center1 = centerImagePart(data, 400, 400, 496, 183);
ctx.drawImage(data, center1.x, center1.y, center1.width, center1.height);
ctx.rotate(-6 * (Math.PI / 180));
ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.rotate(160 * (Math.PI / 180));
ctx.translate(-(canvas.width / 2), -(canvas.height / 2));
const center2 = centerImagePart(data, 75, 75, 625, 55);
ctx.drawImage(data, center2.x, center2.y, center2.width, center2.height);
ctx.rotate(-160 * (Math.PI / 180));
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'worthless.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'worthless.png'));
const { body } = await request.get(image);
const data = await loadImage(body);
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.rotate(6 * (Math.PI / 180));
const center1 = centerImagePart(data, 400, 400, 496, 183);
ctx.drawImage(data, center1.x, center1.y, center1.width, center1.height);
ctx.rotate(-6 * (Math.PI / 180));
ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.rotate(160 * (Math.PI / 180));
ctx.translate(-(canvas.width / 2), -(canvas.height / 2));
const center2 = centerImagePart(data, 75, 75, 625, 55);
ctx.drawImage(data, center2.x, center2.y, center2.width, center2.height);
ctx.rotate(-160 * (Math.PI / 180));
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'worthless.png' }] });
}
};