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
+18 -22
View File
@@ -51,27 +51,23 @@ module.exports = class RipCommand extends Command {
async run(msg, { user, cause }) {
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rip.png'));
const { body } = await request.get(avatarURL);
const avatar = await loadImage(body);
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 194, 399, 500, 500);
greyscale(ctx, 194, 399, 500, 500);
ctx.textBaseline = 'top';
ctx.textAlign = 'center';
ctx.font = this.client.fonts.get('CoffinStone.otf').toCanvasString(62);
ctx.fillStyle = 'black';
ctx.fillText(user.username, 438, 330, 500);
ctx.fillStyle = 'white';
if (cause) ctx.fillText(cause, 438, 910, 500);
ctx.font = this.client.fonts.get('CoffinStone.otf').toCanvasString(37);
ctx.fillText('In Loving Memory of', 438, 292);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rip.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', 'rip.png'));
const { body } = await request.get(avatarURL);
const avatar = await loadImage(body);
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 194, 399, 500, 500);
greyscale(ctx, 194, 399, 500, 500);
ctx.textBaseline = 'top';
ctx.textAlign = 'center';
ctx.font = this.client.fonts.get('CoffinStone.otf').toCanvasString(62);
ctx.fillStyle = 'black';
ctx.fillText(user.username, 438, 330, 500);
ctx.fillStyle = 'white';
if (cause) ctx.fillText(cause, 438, 910, 500);
ctx.font = this.client.fonts.get('CoffinStone.otf').toCanvasString(37);
ctx.fillText('In Loving Memory of', 438, 292);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rip.png' }] });
}
};