diff --git a/README.md b/README.md index 1eff33d8..1685e169 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Xiao is a Discord bot coded in JavaScript with 6. Run `npm i -g pm2` to install PM2. 7. Run `pm2 start Xiao.js --name xiao` to run the bot. -## Commands (340) +## Commands (341) ### Utility: * **eval:** Executes JavaScript code. @@ -293,6 +293,7 @@ Xiao is a Discord bot coded in JavaScript with * **illegal:** Makes President Trump make your text illegal. * **invert:** Draws an image or a user's avatar but inverted. * **kyon-gun:** Draws an image or a user's avatar behind Kyon shooting a gun. +* **lisa-presentation:** Sends a "Lisa Presentation" meme with the presentation of your choice. * **meme-gen:** Sends a meme with the text and background of your choice. * **minecraft-skin:** Sends the Minecraft skin for a user. * **needs-more-jpeg:** Draws an image or a user's avatar as a low quality JPEG. diff --git a/assets/images/lisa-presentation.png b/assets/images/lisa-presentation.png new file mode 100644 index 00000000..2a765514 Binary files /dev/null and b/assets/images/lisa-presentation.png differ diff --git a/commands/image-edit/lisa-presentation.js b/commands/image-edit/lisa-presentation.js new file mode 100644 index 00000000..0a6b21ce --- /dev/null +++ b/commands/image-edit/lisa-presentation.js @@ -0,0 +1,47 @@ +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', 'Noto-Regular.ttf'), { family: 'Noto' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' }); + +module.exports = class LisaPresentationCommand extends Command { + constructor(client) { + super(client, { + name: 'lisa-presentation', + aliases: ['lisa'], + group: 'image-edit', + memberName: 'lisa-presentation', + description: 'Sends a "Lisa Presentation" meme with the presentation of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'text', + prompt: 'What should the text of the presentation be?', + type: 'string', + max: 280 + } + ] + }); + } + + async run(msg, { text }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'lisa-presentation.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.font = '24px Noto'; + ctx.textAlign = 'center'; + const lines = await wrapText(ctx, text, 330); + for (let i = 0; i < lines.length; i++) { + const textHeight = 95 + (i * 24) + (i * 10); + ctx.fillText(lines[i], base.width / 2, textHeight); + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'lisa-presentation.png' }] }); + } +}; diff --git a/package.json b/package.json index 6f40554e..02218e75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "102.2.0", + "version": "102.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {