mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Improve Illegal text wrapping
This commit is contained in:
@@ -728,7 +728,7 @@ Total: 554
|
||||
* **gru-plan:** Sends a Gru's Plan meme with steps of your choice.
|
||||
* **i-fear-no-man:** Sends a "I fear no man" meme with the text of your choice.
|
||||
* **if-those-kids-could-read:** Sends a "If those kids could read, they'd be very upset" meme with the text of your choice.
|
||||
* **illegal:** Makes President Trump make your text illegal.
|
||||
* **illegal:** Makes Donald Trump make your text illegal.
|
||||
* **kyon-gun:** Draws an image or a user's avatar behind Kyon shooting a gun.
|
||||
* **like:** Sends an "Everyone Liked That" meme with the image of your choice.
|
||||
* **lisa-presentation:** Sends a "Lisa Presentation" meme with the presentation of your choice.
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const { drawText } = require('node-canvas-text');
|
||||
const GIFEncoder = require('gifencoder');
|
||||
const opentype = require('opentype.js');
|
||||
const path = require('path');
|
||||
const { streamToArray } = require('../../util/Util');
|
||||
const frames = require('../../assets/json/illegal');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Impact.ttf'), { family: 'Impact' });
|
||||
const impactFont = opentype.loadSync(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Impact.ttf'));
|
||||
|
||||
module.exports = class IllegalCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -13,7 +16,7 @@ module.exports = class IllegalCommand extends Command {
|
||||
aliases: ['is-now-illegal', 'trump'],
|
||||
group: 'edit-meme',
|
||||
memberName: 'illegal',
|
||||
description: 'Makes President Trump make your text illegal.',
|
||||
description: 'Makes Donald Trump make your text illegal.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 30
|
||||
@@ -76,8 +79,19 @@ module.exports = class IllegalCommand extends Command {
|
||||
}
|
||||
ctx.textBaseline = 'top';
|
||||
ctx.font = '20px Impact';
|
||||
const maxLen = frame.corners[1][0] - frame.corners[0][0];
|
||||
ctx.fillText(`${text}\n${verb} NOW\nILLEGAL`, frame.corners[0][0], frame.corners[0][1], maxLen);
|
||||
const rect = {
|
||||
x: frame.corners[0][0],
|
||||
y: frame.corners[1][0],
|
||||
width: frame.corners[0][0],
|
||||
height: frame.corners[0][1]
|
||||
};
|
||||
drawText(ctx, `${text}\n${verb} NOW\nILLEGAL`, impactFont, rect, {
|
||||
minSize: 5,
|
||||
maxSize: 20,
|
||||
hAlign: 'center',
|
||||
wAlign: 'center',
|
||||
textPadding: 5
|
||||
});
|
||||
encoder.addFrame(ctx);
|
||||
}
|
||||
encoder.finish();
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.37.3",
|
||||
"version": "119.37.4",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
@@ -53,7 +53,9 @@
|
||||
"moment": "^2.29.1",
|
||||
"moment-duration-format": "^2.3.2",
|
||||
"moment-timezone": "^0.5.31",
|
||||
"node-canvas-text": "^1.0.2",
|
||||
"node-superfetch": "^0.1.10",
|
||||
"opentype.js": "^1.3.3",
|
||||
"pokersolver": "^2.1.4",
|
||||
"random-js": "^2.1.0",
|
||||
"rss-parser": "^3.9.0",
|
||||
|
||||
Reference in New Issue
Block a user