License Plate Command

This commit is contained in:
Dragon Fire
2020-12-16 16:55:45 -05:00
parent 2ee2e82200
commit 1d5f6c7088
5 changed files with 62 additions and 2 deletions
+55
View File
@@ -0,0 +1,55 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage, registerFont } = require('canvas');
const path = require('path');
const { wrapText } = require('../../util/Canvas');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'LicensePlate.ttf'), { family: 'License Plate' });
module.exports = class LicensePlateCommand extends Command {
constructor(client) {
super(client, {
name: 'license-plate',
group: 'edit-image',
memberName: 'license-plate',
description: 'Creates a license plate with the text of your choice.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Dave Hansen',
url: 'https://www.fontspace.com/dave-hansen',
reason: 'License Plate Font',
reasonURL: 'https://www.fontspace.com/license-plate-font-f3359'
},
{
name: 'Pin Clipart',
url: 'https://www.pinclipart.com/',
reason: 'Image',
reasonURL: 'https://www.pinclipart.com/maxpin/bJxii/'
}
],
args: [
{
key: 'text',
prompt: 'What text should the license plate say?',
type: 'string',
max: 10
}
]
});
}
async run(msg, { text }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'license-plate.png'));
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = '180px License Plate';
ctx.fillText(text.toUpperCase(), base.width / 2, base.height / 2, 700);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'license-plate.png' }] });
}
};