Easier error location

This commit is contained in:
Dragon Fire
2024-03-29 16:53:15 -04:00
parent 2cec48fa2a
commit 4c76916156
+14 -18
View File
@@ -66,23 +66,19 @@ module.exports = class PokedexBoxSpriteCommand extends Command {
}
async run(msg, { pokemon }) {
try {
if (!this.client.pokemon.sprites) await this.client.pokemon.loadSprites();
const canvas = createCanvas(250, 250);
const ctx = canvas.getContext('2d');
const x = 40 * (this.id % 12);
const y = Math.floor(this.id / 12) * 30;
ctx.imageSmoothingEnabled = false;
ctx.drawImage(this.client.pokemon.sprites, x, y, 40, 30, 0, 0, 250, 250);
cropToContent(ctx, canvas, canvas.width, canvas.height);
return msg.say(`#${pokemon.displayID} - ${pokemon.name}`, {
files: [{
attachment: canvas.toBuffer(),
name: 'box.png'
}]
});
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
if (!this.client.pokemon.sprites) await this.client.pokemon.loadSprites();
const canvas = createCanvas(250, 250);
const ctx = canvas.getContext('2d');
const x = 40 * (this.id % 12);
const y = Math.floor(this.id / 12) * 30;
ctx.imageSmoothingEnabled = false;
ctx.drawImage(this.client.pokemon.sprites, x, y, 40, 30, 0, 0, 250, 250);
cropToContent(ctx, canvas, canvas.width, canvas.height);
return msg.say(`#${pokemon.displayID} - ${pokemon.name}`, {
files: [{
attachment: canvas.toBuffer(),
name: 'box.png'
}]
});
}
};