mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
const Command = require('../../structures/Command');
|
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
|
const path = require('path');
|
|
const { shortenText } = require('../../util/Canvas');
|
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'akbar.ttf'), { family: 'Akbar' });
|
|
|
|
module.exports = class LisaPresentationCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'bart-chalkboard',
|
|
aliases: ['bart'],
|
|
group: 'meme-gen',
|
|
memberName: 'bart-chalkboard',
|
|
description: 'Sends a "Bart Chalkboard" meme with the text of your choice.',
|
|
throttling: {
|
|
usages: 1,
|
|
duration: 10
|
|
},
|
|
clientPermissions: ['ATTACH_FILES'],
|
|
credit: [
|
|
{
|
|
name: '20th Century Fox',
|
|
url: 'https://www.foxmovies.com/',
|
|
reason: 'Image, Original "The Simpsons" Show',
|
|
reasonURL: 'http://www.simpsonsworld.com/'
|
|
},
|
|
{
|
|
name: 'Jon Bernhardt',
|
|
url: 'http://web.mit.edu/jonb/www/',
|
|
reason: 'Akbar Font',
|
|
reasonURL: 'https://www.wobblymusic.com/groening/akbar.html'
|
|
}
|
|
],
|
|
args: [
|
|
{
|
|
key: 'text',
|
|
prompt: 'What should the text on the chalkboard be?',
|
|
type: 'string',
|
|
max: 50
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
async run(msg, { text }) {
|
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'bart-chalkboard.png'));
|
|
const canvas = createCanvas(base.width, base.height);
|
|
const ctx = canvas.getContext('2d');
|
|
ctx.drawImage(base, 0, 0);
|
|
ctx.textAlign = 'top';
|
|
ctx.font = '19px Akbar';
|
|
ctx.fillText(shortenText(ctx, `${text}\n`.repeat(12).trim(), 500), 30, 27);
|
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'bart-chalkboard.png' }] });
|
|
}
|
|
};
|