mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Word wrap in illegal
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||||
const { stripIndents } = require('common-tags');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { shortenText } = require('../../util/Canvas');
|
const { wrapText } = require('../../util/Canvas');
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
|
||||||
@@ -25,6 +24,7 @@ module.exports = class IllegalCommand extends Command {
|
|||||||
key: 'text',
|
key: 'text',
|
||||||
prompt: 'What should the text of the bill be?',
|
prompt: 'What should the text of the bill be?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
max: 20,
|
||||||
parse: text => text.toUpperCase()
|
parse: text => text.toUpperCase()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -45,12 +45,15 @@ module.exports = class IllegalCommand extends Command {
|
|||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.drawImage(base, 0, 0);
|
ctx.drawImage(base, 0, 0);
|
||||||
ctx.rotate(7 * (Math.PI / 180));
|
ctx.rotate(7 * (Math.PI / 180));
|
||||||
ctx.font = '45px Noto';
|
const illegalText = `${text} ${verb} NOW ILLEGAL.`;
|
||||||
ctx.fillText(stripIndents`
|
let fontSize = 45;
|
||||||
${shortenText(ctx, text, 200)}
|
ctx.font = `${fontSize}px Noto`;
|
||||||
${verb} NOW
|
while (ctx.measureText(illegalText).width > 550) {
|
||||||
ILLEGAL.
|
fontSize -= 1;
|
||||||
`, 750, 290);
|
ctx.font = `${fontSize}px Noto`;
|
||||||
|
}
|
||||||
|
ctx.fillText(wrapText(ctx, illegalText, 200).join('\n'), 750, 290);
|
||||||
|
ctx.rotate(-7 * (Math.PI / 180));
|
||||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "91.1.5",
|
"version": "91.1.6",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user