mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 16:19:12 +02:00
Fix
This commit is contained in:
@@ -69,7 +69,10 @@ module.exports = class TweetCommand extends Command {
|
|||||||
ctx.font = '23px Noto';
|
ctx.font = '23px Noto';
|
||||||
const lines = await wrapText(ctx, text, 710);
|
const lines = await wrapText(ctx, text, 710);
|
||||||
const lineBreakLen = text.split('\n').length;
|
const lineBreakLen = text.split('\n').length;
|
||||||
const linesLen = (23 * lines.length) + (23 * (lineBreakLen - 1)) + (9 * lines.length) + (9 * (lineBreakLen - 1));
|
const linesLen = (23 * lines.length)
|
||||||
|
+ (23 * (lineBreakLen - 1))
|
||||||
|
+ (9 * (lines.length - 1))
|
||||||
|
+ (9 * (lineBreakLen - 1));
|
||||||
canvas.height += linesLen;
|
canvas.height += linesLen;
|
||||||
const likes = Math.floor(Math.random() * 100000) + 1;
|
const likes = Math.floor(Math.random() * 100000) + 1;
|
||||||
const retweets = Math.floor(Math.random() * 100000) + 1;
|
const retweets = Math.floor(Math.random() * 100000) + 1;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ module.exports = class MemeGenModernCommand extends Command {
|
|||||||
const lineBreakLen = text.split('\n').length;
|
const lineBreakLen = text.split('\n').length;
|
||||||
const linesLen = (23 * lines.length) + (23 * (lineBreakLen - 1)) + (9 * lines.length) + (9 * (lineBreakLen - 1));
|
const linesLen = (23 * lines.length) + (23 * (lineBreakLen - 1)) + (9 * lines.length) + (9 * (lineBreakLen - 1));
|
||||||
canvas.height += linesLen;
|
canvas.height += linesLen;
|
||||||
|
console.log(linesLen);
|
||||||
ctx.textBaseline = 'top';
|
ctx.textBaseline = 'top';
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = 'white';
|
||||||
ctx.fillRect(0, 0, base.width, linesLen);
|
ctx.fillRect(0, 0, base.width, linesLen);
|
||||||
@@ -73,7 +74,7 @@ module.exports = class MemeGenModernCommand extends Command {
|
|||||||
ctx.drawImage(base, 0, linesLen);
|
ctx.drawImage(base, 0, linesLen);
|
||||||
const attachment = canvas.toBuffer();
|
const attachment = canvas.toBuffer();
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'modern-meme-gen.png' }] });
|
return msg.say({ files: [{ attachment, name: 'meme-gen-modern.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user