From 7387f1c6f01eeacc5d8860b99888e9b94ab1571e Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 21 Apr 2020 11:05:52 -0400 Subject: [PATCH] Fix --- commands/edit-image/jeopardy-question.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commands/edit-image/jeopardy-question.js b/commands/edit-image/jeopardy-question.js index 517882fa..972f511e 100644 --- a/commands/edit-image/jeopardy-question.js +++ b/commands/edit-image/jeopardy-question.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { createCanvas, loadImage, registerFont } = require('canvas'); +const { createCanvas, registerFont } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OPTIKorinna-Agency.otf'), { family: 'Korinna' }); @@ -51,11 +51,14 @@ module.exports = class JeopardyQuestionCommand extends Command { ctx.fillStyle = 'white'; ctx.font = '62px Korinna'; const lines = await wrapText(ctx, text.toUpperCase(), 813); - const topMost = (canvas.height / 2) - (((48 * lines.length) / 2) + ((27 * (lines.length - 1)) / 2)); - ctx.fillStyle = 'black'; - ctx.fillText(lines.join('\n'), (canvas.width / 2) + 6, topMost + 6); - ctx.fillStyle = 'white'; - ctx.fillText(lines.join('\n'), canvas.width / 2, topMost); + const topMost = (canvas.height / 2) - (((52 * lines.length) / 2) + ((20 * (lines.length - 1)) / 2)); + for (let i = 0; i < lines.length; i++) { + const height = topMost + ((52 + 20) * i); + ctx.fillStyle = 'black'; + ctx.fillText(lines[i], (canvas.width / 2) + 6, height + 6); + ctx.fillStyle = 'white'; + ctx.fillText(lines[i], canvas.width / 2, height); + } return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'jeopardy-question.png' }] }); } };