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
+11 -15
View File
@@ -27,20 +27,16 @@ module.exports = class CircleCommand extends Command {
}
async run(msg, { image }) {
try {
const { body } = await request.get(image);
const data = await loadImage(body);
const dimensions = data.width <= data.height ? data.width : data.height;
const canvas = createCanvas(dimensions, dimensions);
const ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, canvas.height / 2, 0, Math.PI * 2);
ctx.closePath();
ctx.clip();
ctx.drawImage(data, (canvas.width / 2) - (data.width / 2), (canvas.height / 2) - (data.height / 2));
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'circle.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
const { body } = await request.get(image);
const data = await loadImage(body);
const dimensions = data.width <= data.height ? data.width : data.height;
const canvas = createCanvas(dimensions, dimensions);
const ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, canvas.height / 2, 0, Math.PI * 2);
ctx.closePath();
ctx.clip();
ctx.drawImage(data, (canvas.width / 2) - (data.width / 2), (canvas.height / 2) - (data.height / 2));
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'circle.png' }] });
}
};