diff --git a/README.md b/README.md index 923aa10d..d0a637d4 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,13 @@ 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 (345) +## Related Bots + +* [Rando Cardrissian](https://github.com/dragonfire535/rando-cardrissian) is a Cards Against Humanity bot, who's features were originally built into Xiao. +* [Storyteller](https://github.com/dragonfire535/storyteller) is a Mafia bot made for Discord's 2019 Hack Week, who's features were originally built into Xiao. +* [Meme Poster](https://github.com/dragonfire535/meme-poster) is a meme-posting webhook, inspired by an idea that started as part of Xiao. + +## Commands (346) ### Utility: * **eval:** Executes JavaScript code. @@ -312,6 +318,7 @@ Xiao is a Discord bot coded in JavaScript with * **nike-ad:** Sends a "Believe in Something" Nike Ad meme with the text of your choice. * **osu-signature:** Creates a card based on an osu! user's stats. * **pixelize:** Draws an image or a user's avatar pixelized. +* **plankton-plan:** Sends a Plankton's Plan meme with steps of your choice. * **pokemon-fusion:** Fuses two Generation I Pokémon together. * **rainbow:** Draws a rainbow over an image or a user's avatar. * **rejected:** Draws a "rejected" stamp over an image or a user's avatar. diff --git a/assets/images/plankton-plan.png b/assets/images/plankton-plan.png new file mode 100644 index 00000000..f90c9ec0 Binary files /dev/null and b/assets/images/plankton-plan.png differ diff --git a/commands/image-edit/plankton-plan.js b/commands/image-edit/plankton-plan.js new file mode 100644 index 00000000..7068234a --- /dev/null +++ b/commands/image-edit/plankton-plan.js @@ -0,0 +1,82 @@ +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 = [[240, 63], [689, 63], [705, 380], [220, 380]]; + +module.exports = class PlanktonPlanCommand extends Command { + constructor(client) { + super(client, { + name: 'plankton-plan', + aliases: ['planktons-plan', 'plankton'], + group: 'image-edit', + memberName: 'plankton-plan', + description: 'Sends a Plankton\'s Plan meme with steps of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Spongebob', + url: 'https://www.nick.com/shows/spongebob-squarepants' + }, + { + name: 'Google Noto Fonts', + url: 'https://www.google.com/get/noto/' + } + ], + args: [ + { + key: 'step1', + label: 'step 1', + prompt: 'What should the first step of Plankton\'s plan be?', + type: 'string', + max: 150 + }, + { + key: 'step2', + label: 'step 2', + prompt: 'What should the second step of Plankton\'s plan be?', + type: 'string', + max: 150 + }, + { + key: 'step3', + label: 'step 3', + prompt: 'What should the third step of Plankton\'s plan be?', + type: 'string', + max: 150 + } + ] + }); + } + + async run(msg, { step1, step2, step3 }) { + const steps = [step1, step2, step3, step3]; + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'plankton-plan.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.fillStyle = 'black'; + ctx.textBaseline = 'top'; + let i = 0; + for (const [x, y] of coord) { + ctx.font = '35px Noto'; + const step = steps[i]; + let fontSize = 35; + while (ctx.measureText(step).width > 720) { + fontSize -= 1; + ctx.font = `${fontSize}px Noto`; + } + const lines = await wrapText(ctx, step, 252); + ctx.fillText(lines.join('\n'), x, y); + i++; + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'plankton-plan.png' }] }); + } +}; diff --git a/package.json b/package.json index f4c9fc93..bf53cb35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "107.4.1", + "version": "107.5.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {