diff --git a/README.md b/README.md index be53887b..ca10f9ff 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 470 +Total: 471 ### Utility: @@ -622,6 +622,7 @@ Total: 470 * **beautiful:** Draws a user's avatar over Gravity Falls' "Oh, this? This is beautiful." meme. * **catch:** Catch users, revealing who is something. * **challenger:** Draws an image or a user's avatar over Smash Bros.'s "Challenger Approaching" screen. +* **change-my-mind:** Sends a "Change My Mind" meme with the text of your choice. * **chi-idea:** Sends a "Daddy, I've got an idea!" Takagi-san meme with the text of your choice. * **cursed-sponge:** Sends a cursed sponge duplicated however many times you want. * **dear-liberals:** Sends a "Dear Liberals" meme with words of your choice. @@ -985,6 +986,7 @@ here. * book ([Books API](https://developers.google.com/books/)) * calendar ([Calendar API](https://developers.google.com/calendar/)) * catch ([Noto Font](https://www.google.com/get/noto/)) + * change-my-mind ([Noto Font](https://www.google.com/get/noto/)) * dear-liberals ([Oswald Font](https://fonts.google.com/specimen/Oswald)) * demotivational ([Noto Font](https://www.google.com/get/noto/)) * edd-facts-book ([Noto Font](https://www.google.com/get/noto/)) @@ -1376,6 +1378,8 @@ here. * steam-card ([Original Design](https://steamcommunity.com/tradingcards/)) * steam-now-playing (Original Design) * steam-now-playing-classic (Original Design) +- [Steven Crowder](https://www.youtube.com/StevenCrowder) + * change-my-mind (Image) - [Straw Poll](https://www.strawpoll.me/) * strawpoll ([API](https://github.com/strawpoll/strawpoll/wiki/API)) - [Superpower Wiki](https://powerlisting.fandom.com/wiki/Superpower_Wiki) diff --git a/assets/images/change-my-mind.png b/assets/images/change-my-mind.png new file mode 100644 index 00000000..b888d54c Binary files /dev/null and b/assets/images/change-my-mind.png differ diff --git a/commands/edit-meme/change-my-mind.js b/commands/edit-meme/change-my-mind.js new file mode 100644 index 00000000..43bee961 --- /dev/null +++ b/commands/edit-meme/change-my-mind.js @@ -0,0 +1,65 @@ +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 ChangeMyMindCommand extends Command { + constructor(client) { + super(client, { + name: 'change-my-mind', + aliases: ['change-mind', 'mind-change'], + group: 'edit-meme', + memberName: 'change-my-mind', + description: 'Sends a "Change My Mind" meme with the text of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Steven Crowder', + url: 'https://www.youtube.com/StevenCrowder', + reason: 'Image', + reasonURL: 'https://twitter.com/scrowder/status/964577508447449088' + }, + { + name: 'Google', + url: 'https://www.google.com/', + reason: 'Noto Font', + reasonURL: 'https://www.google.com/get/noto/' + } + ], + args: [ + { + key: 'text', + prompt: 'What should be on the poster?', + type: 'string', + max: 500 + } + ] + }); + } + + async run(msg, { text }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'change-my-mind.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.textBaseline = 'top'; + ctx.drawImage(base, 0, 0); + ctx.rotate(6 * (Math.PI / 180)); + ctx.font = '28px Noto'; + let fontSize = 28; + while (ctx.measureText(text).width > 309) { + fontSize--; + ctx.font = `${fontSize}px Noto`; + } + const lines = await wrapText(ctx, text, 206); + ctx.fillText(lines.join('\n'), 184, 253, 206); + ctx.rotate(-6 * (Math.PI / 180)); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'change-my-mind.png' }] }); + } +}; diff --git a/package.json b/package.json index 16d10725..1f860a3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.13.4", + "version": "116.14.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {