diff --git a/README.md b/README.md index 75550cf0..c9fd8248 100644 --- a/README.md +++ b/README.md @@ -618,6 +618,7 @@ Total: 452 * **meme-gen-modern:** Sends a meme with the text and image of your choice. * **new-password:** Sends a "Weak Password/Strong Password" meme with the passwords of your choice. * **nike-ad:** Sends a "Believe in Something" Nike Ad meme with the text of your choice. +* **phoebe-teaching-joey:** Sends a "Phoebe Teaching Joey" meme with text of your choice. * **plankton-plan:** Sends a Plankton's Plan meme with steps of your choice. * **scroll-of-truth:** Sends a "Scroll of Truth" meme with the text of your choice. * **skyrim-skill:** Sends a "Skyrim Skill" meme with the skill and image of your choice. @@ -968,6 +969,7 @@ here. * new-password ([Noto Font](https://www.google.com/get/noto/)) * nike-ad ([Noto Font](https://www.google.com/get/noto/)) * periodic-table ([Noto Font](https://www.google.com/get/noto/)) + * phoebe-teaching-joey ([Noto Font](https://www.google.com/get/noto/)) * plankton-plan ([Noto Font](https://www.google.com/get/noto/)) * scroll-of-truth ([Noto Font](https://www.google.com/get/noto/)) * sos ([Noto Font](https://www.google.com/get/noto/)) @@ -1410,6 +1412,8 @@ here. * this-for-that ([API](http://itsthisforthat.com/api.php)) - [WAIT: What Anime Is This?](https://trace.moe/) * what-anime ([API](https://soruly.github.io/trace.moe/#/)) +- [Warner Bros.](https://www.warnerbros.com/) + * phoebe-teaching-joey ([Images, Original "Friends" TV Series](https://www.warnerbros.com/tv/friends/)) - [Wattpad](https://www.wattpad.com/) * wattpad ([API](https://www.wattpad.com/developer/docs/api)) - [wikiHow](https://www.wikihow.com/Main-Page) diff --git a/assets/images/phoebe-teaching-joey.png b/assets/images/phoebe-teaching-joey.png new file mode 100644 index 00000000..81b56598 Binary files /dev/null and b/assets/images/phoebe-teaching-joey.png differ diff --git a/commands/edit-meme/phoebe-teaching-joey.js b/commands/edit-meme/phoebe-teaching-joey.js new file mode 100644 index 00000000..53032cc4 --- /dev/null +++ b/commands/edit-meme/phoebe-teaching-joey.js @@ -0,0 +1,100 @@ +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' }); +const coord = [ + [[107, 135], [439, 135]], + [[105, 328], [443, 328]], + [[120, 497], [445, 497]], + [[116, 712], [420, 712]] +]; + +module.exports = class PhoebeTeachingJoeyCommand extends Command { + constructor(client) { + super(client, { + name: 'phoebe-teaching-joey', + aliases: ['phoebe', 'phoebe-teach', 'joey', 'phoebe-teach-joey'], + group: 'edit-meme', + memberName: 'phoebe-teaching-joey', + description: 'Sends a "Phoebe Teaching Joey" meme with text of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Warner Bros.', + url: 'https://www.warnerbros.com/', + reason: 'Images, Original "Friends" TV Series', + reasonURL: 'https://www.warnerbros.com/tv/friends/' + }, + { + name: 'Google', + url: 'https://www.google.com/', + reason: 'Noto Font', + reasonURL: 'https://www.google.com/get/noto/' + } + ], + args: [ + { + key: 'correct', + prompt: 'What should Phoebe try to teach Joey?', + type: 'string', + validate: correct => { + if (correct.split(' ') < 3) return 'Please provide at least three words.'; + if (correct.length > 50) return 'Please keep the text below or exactly 50 characters.'; + return true; + }, + parse: correct => { + const words = correct.split(' '); + const divided = Math.ceil(words.length / 3); + const first = words.slice(0, divided).join(' '); + const second = words.slice(divided, divided * 2).join(' '); + const third = words.slice(divided * 2, words.length).join(' '); + return [first, second, third]; + } + }, + { + key: 'incorrect', + prompt: 'What should Joey repeat back?', + type: 'string', + max: 50 + } + ] + }); + } + + async run(msg, { correct, incorrect }) { + const steps = [...correct, incorrect]; + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'phoebe-teaching-joey.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.fillStyle = '#e3e35f'; + ctx.textBaseline = 'top'; + ctx.textAlign = 'center'; + let i = 0; + for (const coords of coord) { + let j = 0; + for (const [x, y] of coords) { + ctx.font = '15px Noto'; + let step = steps[i]; + if (step === incorrect && j === 0) step = correct.join(' '); + let fontSize = 15; + while (ctx.measureText(step).width > 390) { + fontSize -= 1; + ctx.font = `${fontSize}px Noto`; + } + const lines = await wrapText(ctx, step, 260); + ctx.fillText(lines.join('\n'), x, y); + j++; + } + i++; + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'phoebe-teaching-joey.png' }] }); + } +}; diff --git a/package.json b/package.json index 2863f777..fce85b5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "115.2.2", + "version": "115.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {