mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Adjust jeopardy clue cards
This commit is contained in:
@@ -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' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user