diff --git a/README.md b/README.md index e764dc2a..d9570482 100644 --- a/README.md +++ b/README.md @@ -253,7 +253,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 533 +Total: 534 ### Utility: @@ -734,6 +734,7 @@ Total: 533 * **this-guy:** Draws an image or a user's avatar over the "Get a load of this guy" meme. * **thug-life:** Draws "Thug Life" over an image or a user's avatar. * **to-be-continued:** Draws an image with the "To Be Continued..." arrow. +* **tuxedo-pooh:** Sends a "Tuxedo Winnie the Pooh" meme with the text of your choice. * **two-buttons:** Sends a "Two Buttons" meme with the buttons of your choice. * **ultimate-tattoo:** Draws an image or a user's avatar as "The Ultimate Tattoo". * **vietnam-flashbacks:** Edits Vietnam flashbacks behind an image or a user's avatar. @@ -1022,6 +1023,7 @@ here. * beautiful ([Original "Gravity Falls" Show](https://disneynow.com/shows/gravity-falls)) * girl-worth-fighting-for ([Original "Mulan" Movie](https://movies.disney.com/mulan)) * he-lives-in-you ([Image, Original "The Lion King" Movie](https://movies.disney.com/the-lion-king)) + * tuxedo-pooh ([Original "Winnie the Pooh" Movie](https://winniethepooh.disney.com/)) * worthless ([Original "Gravity Falls" Show](https://disneynow.com/shows/gravity-falls)) - [Dog CEO](https://dog.ceo/) * dog ([Dog API](https://dog.ceo/dog-api/)) @@ -1131,6 +1133,7 @@ here. * steam-now-playing-classic ([Noto Font](https://www.google.com/get/noto/)) * subtitle ([Noto Font](https://www.google.com/get/noto/)) * translate ([Google Translate](https://translate.google.com/)) + * tuxedo-pooh ([Noto Font](https://www.google.com/get/noto/)) * tweet ([Noto Font](https://www.google.com/get/noto/)) * two-buttons ([Noto Font](https://www.google.com/get/noto/)) * youtube ([YouTube Data API](https://developers.google.com/youtube/v3/)) diff --git a/assets/images/tuxedo-pooh.png b/assets/images/tuxedo-pooh.png new file mode 100644 index 00000000..ea70b720 Binary files /dev/null and b/assets/images/tuxedo-pooh.png differ diff --git a/commands/edit-meme/tuxedo-pooh.js b/commands/edit-meme/tuxedo-pooh.js new file mode 100644 index 00000000..ee2d80be --- /dev/null +++ b/commands/edit-meme/tuxedo-pooh.js @@ -0,0 +1,90 @@ +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 TuxedoPoohCommand extends Command { + constructor(client) { + super(client, { + name: 'tuxedo-pooh', + aliases: ['tuxedo-winnie', 'tuxedo-winnie-the-pooh', 'tux-pooh', 'tux-winnie', 'tux-winnie-the-pooh'], + group: 'edit-meme', + memberName: 'tuxedo-pooh', + description: 'Sends a "Tuxedo Winnie the Pooh" meme with the text of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Disney', + url: 'https://www.disney.com/', + reason: 'Original "Winnie the Pooh" Movie', + reasonURL: 'https://winniethepooh.disney.com/' + }, + { + name: 'Google', + url: 'https://www.google.com/', + reason: 'Noto Font', + reasonURL: 'https://www.google.com/get/noto/' + } + ], + args: [ + { + key: 'normal', + prompt: 'What text should be the normal Pooh?', + type: 'string', + max: 500 + }, + { + key: 'tuxedo', + prompt: 'What text should be the tuxedo Pooh?', + type: 'string', + max: 500 + } + ] + }); + } + + async run(msg, { normal, tuxedo }) { + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'tuxedo-pooh.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 = '50px Noto'; + let fontSize = 50; + while (ctx.measureText(normal).width > 1320) { + fontSize--; + ctx.font = `${fontSize}px Noto`; + } + const normalLines = await wrapText(ctx, normal, 440); + const normalTopMost = 145 - (((fontSize * normalLines.length) / 2) + ((10 * (normalLines.length - 1)) / 2)); + for (let i = 0; i < normalLines.length; i++) { + const height = normalTopMost + ((fontSize + 10) * i); + ctx.fillText(nahLinormalLinesnes[i], 560, height); + } + ctx.font = '50px Noto'; + fontSize = 50; + while (ctx.measureText(tuxedo).width > 1320) { + fontSize--; + ctx.font = `${fontSize}px Noto`; + } + const tuxedoLines = await wrapText(ctx, tuxedo, 440); + const tuxedoTopMost = 436 - (((fontSize * tuxedoLines.length) / 2) + ((10 * (tuxedoLines.length - 1)) / 2)); + for (let i = 0; i < tuxedoLines.length; i++) { + const height = tuxedoTopMost + ((fontSize + 10) * i); + ctx.fillText(tuxedoLines[i], 560, height); + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'tuxedo-pooh.png' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index d30f7c4c..57caff4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.14.1", + "version": "119.15.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {