mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Fix
This commit is contained in:
@@ -54,20 +54,18 @@ module.exports = class SkyrimSkillCommand extends Command {
|
||||
const { body } = await request.get(image);
|
||||
const base = await loadImage(body);
|
||||
const plate = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'skyrim-skill.png'));
|
||||
const ratio = base.width / base.height;
|
||||
const height = Math.round(plate.width / ratio);
|
||||
const canvas = createCanvas(base.width, base.height + height);
|
||||
const ratio = plate.width / plate.height;
|
||||
const height = Math.round(base.width / ratio);
|
||||
const canvas = createCanvas(plate.width, plate.height + height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
const fontSize = Math.round(77 / ratio);
|
||||
ctx.font = `normal bold ${fontSize}px Futura`;
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = 'normal bold 77px Futura';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'top';
|
||||
ctx.strokeStyle = 'black';
|
||||
ctx.lineWidth = 10;
|
||||
ctx.strokeText(skill, 189, base.height + 84);
|
||||
ctx.fillText(skill, 189, base.height + 84);
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.fillText(skill, 189 + 5, height + 84 + 3);
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillText(skill, 189, height + 84);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'skyrim-skill.png' }] });
|
||||
|
||||
Reference in New Issue
Block a user