diff --git a/commands/edit-image-text/jeopardy-question.js b/commands/edit-image-text/jeopardy-question.js index 917dee3e..341a0db1 100644 --- a/commands/edit-image-text/jeopardy-question.js +++ b/commands/edit-image-text/jeopardy-question.js @@ -1,7 +1,5 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas } = require('@napi-rs/canvas'); -const { wrapText } = require('../../util/Canvas'); module.exports = class JeopardyQuestionCommand extends Command { constructor(client) { @@ -40,23 +38,7 @@ module.exports = class JeopardyQuestionCommand extends Command { } run(msg, { text }) { - const canvas = createCanvas(1280, 720); - const ctx = canvas.getContext('2d'); - ctx.fillStyle = '#030e78'; - ctx.fillRect(0, 0, canvas.width, canvas.height); - ctx.textAlign = 'center'; - ctx.textBaseline = 'top'; - ctx.fillStyle = 'white'; - ctx.font = this.client.fonts.get('OPTIKorinna-Agency.otf').toCanvasString(62); - const lines = wrapText(ctx, text.toUpperCase(), 813); - 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('image/png'), name: 'jeopardy-question.png' }] }); + const attachment = this.client.registry.commands.get('jeopardy').generateClueCard(text); + return msg.say({ files: [{ attachment, name: 'jeopardy-question.png' }] }); } }; diff --git a/commands/games-sp/jeopardy.js b/commands/games-sp/jeopardy.js index 65275fca..e50a7ed1 100644 --- a/commands/games-sp/jeopardy.js +++ b/commands/games-sp/jeopardy.js @@ -84,7 +84,7 @@ module.exports = class JeopardyCommand extends Command { 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.fillText(lines[i], (canvas.width / 2) + 3, height + 3); ctx.fillStyle = 'white'; ctx.fillText(lines[i], canvas.width / 2, height); }