mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +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 { body } = await request.get(image);
|
||||||
const base = await loadImage(body);
|
const base = await loadImage(body);
|
||||||
const plate = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'skyrim-skill.png'));
|
const plate = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'skyrim-skill.png'));
|
||||||
const ratio = base.width / base.height;
|
const ratio = plate.width / plate.height;
|
||||||
const height = Math.round(plate.width / ratio);
|
const height = Math.round(base.width / ratio);
|
||||||
const canvas = createCanvas(base.width, base.height + height);
|
const canvas = createCanvas(plate.width, plate.height + height);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.drawImage(base, 0, 0);
|
ctx.drawImage(base, 0, 0);
|
||||||
const fontSize = Math.round(77 / ratio);
|
ctx.font = 'normal bold 77px Futura';
|
||||||
ctx.font = `normal bold ${fontSize}px Futura`;
|
|
||||||
ctx.fillStyle = 'white';
|
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'top';
|
ctx.textBaseline = 'top';
|
||||||
ctx.strokeStyle = 'black';
|
ctx.fillStyle = 'black';
|
||||||
ctx.lineWidth = 10;
|
ctx.fillText(skill, 189 + 5, height + 84 + 3);
|
||||||
ctx.strokeText(skill, 189, base.height + 84);
|
ctx.fillStyle = 'white';
|
||||||
ctx.fillText(skill, 189, base.height + 84);
|
ctx.fillText(skill, 189, height + 84);
|
||||||
const attachment = canvas.toBuffer();
|
const attachment = canvas.toBuffer();
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'skyrim-skill.png' }] });
|
return msg.say({ files: [{ attachment, name: 'skyrim-skill.png' }] });
|
||||||
|
|||||||
Reference in New Issue
Block a user