Adjust jeopardy clue cards

This commit is contained in:
Dragon Fire
2024-05-10 00:19:53 -04:00
parent a30e3b987a
commit 6f049246cc
2 changed files with 3 additions and 21 deletions
+2 -20
View File
@@ -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' }] });
}
};
+1 -1
View File
@@ -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);
}