diff --git a/README.md b/README.md index 43dd2566..6f06ee7b 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 501 +Total: 502 ### Utility: @@ -656,6 +656,7 @@ Total: 501 * **genie-rules:** Sends a "There are 4 rules" meme with the text of your choice. * **girl-worth-fighting-for:** Draws an image or a user's avatar as the object of Ling's affection. * **gru-plan:** Sends a Gru's Plan meme with steps 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. * **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. @@ -832,6 +833,7 @@ here. - [20th Century Fox](https://www.foxmovies.com/) * bart-chalkboard ([Image, Original "The Simpsons" Show](http://www.simpsonsworld.com/)) * eat-pant ([Original "The Simpsons" Show](http://www.simpsonsworld.com/)) + * if-those-kids-could-read (Image, Original "King of the Hill" Show) * lisa-presentation ([Image, Original "The Simpsons" Show](http://www.simpsonsworld.com/)) * worse-than-hitler ([Image, Original "Family Guy" Show](https://www.fox.com/family-guy/)) - [@Candasaurus](https://twitter.com/Candasaurus) @@ -1046,6 +1048,7 @@ here. * google-doodle ([Google Doodles API](https://www.google.com/doodles)) * google-feud (Autofill API) * gru-plan ([Noto Font](https://www.google.com/get/noto/)) + * if-those-kids-could-read ([Noto Font](https://www.google.com/get/noto/)) * illegal ([Noto Font](https://www.google.com/get/noto/)) * lisa-presentation ([Noto Font](https://www.google.com/get/noto/)) * map ([Maps Static API](https://developers.google.com/maps/documentation/maps-static/intro)) diff --git a/assets/images/if-those-kids-could-read.png b/assets/images/if-those-kids-could-read.png new file mode 100644 index 00000000..972b5703 Binary files /dev/null and b/assets/images/if-those-kids-could-read.png differ diff --git a/commands/edit-meme/if-those-kids-could-read.js b/commands/edit-meme/if-those-kids-could-read.js new file mode 100644 index 00000000..0b5b1ded --- /dev/null +++ b/commands/edit-meme/if-those-kids-could-read.js @@ -0,0 +1,67 @@ +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 IfThoseKidsCouldReadCommand extends Command { + constructor(client) { + super(client, { + name: 'if-those-kids-could-read', + aliases: ['if-those-kids-could', 'itkcr', 'itkc'], + group: 'edit-meme', + memberName: 'if-those-kids-could-read', + description: 'Sends a "If those kids could read, they\'d be very upset" 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 "King of the Hill" Show' + }, + { + name: 'Google', + url: 'https://www.google.com/', + reason: 'Noto Font', + reasonURL: 'https://www.google.com/get/noto/' + } + ], + args: [ + { + key: 'text', + prompt: 'What should the text of Bobby\'s poster be?', + type: 'string', + max: 500 + } + ] + }); + } + + async run(msg, { text }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'if-those-kids-could-read.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.textAlign = 'center'; + ctx.textBaseline = 'top'; + ctx.font = '40px Noto'; + let fontSize = 40; + while (ctx.measureText(text).width > 560) { + fontSize--; + ctx.font = `${fontSize}px Noto`; + } + const lines = await wrapText(ctx, text, 160); + const topMost = 140 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2)); + for (let i = 0; i < lines.length; i++) { + const height = topMost + ((fontSize + 20) * i); + ctx.fillText(lines[i], 300, height); + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'if-those-kids-could-read.png' }] }); + } +}; diff --git a/package.json b/package.json index 2755f724..17f2a609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.38.0", + "version": "116.39.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {