mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 23:05:04 +02:00
Easier error location
This commit is contained in:
@@ -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'
|
||||
}]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user