diff --git a/README.md b/README.md index d25cfaf6..bd63627c 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 437 +Total: 438 ### Utility: @@ -614,6 +614,7 @@ Total: 437 * **spongebob-burn:** Sends a "Spongebob Throwing Something into a Fire" meme with words of your choice. * **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. +* **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. * **worthless:** Draws an image or a user's avatar over Gravity Falls' "This is worthless." meme. @@ -955,6 +956,7 @@ here. * steam-now-playing ([Noto Font](https://www.google.com/get/noto/)) * steam-now-playing-classic ([Noto Font](https://www.google.com/get/noto/)) * translate ([Google Translate](https://translate.google.com/)) + * two-buttons ([Noto Font](https://www.google.com/get/noto/)) * youtube ([YouTube Data API](https://developers.google.com/youtube/v3/)) - [Google Feud](http://www.googlefeud.com/) * google-feud (Original Game) @@ -1032,6 +1034,8 @@ here. * guesspionage ([Original "Guesspionage" Game](https://www.jackboxgames.com/guesspionage/)) * lie-swatter ([Original "Lie Swatter" Game](https://www.jackboxgames.com/lie-swatter/)) * word-spud ([Original "Word Spud" Game](https://www.jackboxgames.com/word-spud/)) +- [Jake Clark](https://jake-clark.tumblr.com/) + * two-buttons ([Image](https://twitter.com/jakeclarkdude/status/689141113584619524)) - [jasmaa](https://github.com/jasmaa/) * neko-atsume-password ([API URL](https://github.com/jasmaa/nekoatsume-password-learner/blob/master/neko_pswd.py#L4)) - [JellyNeo Item Database](https://items.jellyneo.net/) diff --git a/assets/images/two-buttons.png b/assets/images/two-buttons.png new file mode 100644 index 00000000..8b039882 Binary files /dev/null and b/assets/images/two-buttons.png differ diff --git a/commands/edit-meme/two-buttons.js b/commands/edit-meme/two-buttons.js new file mode 100644 index 00000000..508bb5c6 --- /dev/null +++ b/commands/edit-meme/two-buttons.js @@ -0,0 +1,76 @@ +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 TwoButtonsCommand extends Command { + constructor(client) { + super(client, { + name: 'two-buttons', + aliases: ['buttons', 'button'], + group: 'edit-meme', + memberName: 'two-buttons', + description: 'Sends a "Two Buttons" meme with the buttons of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Google', + url: 'https://www.google.com/', + reason: 'Noto Font', + reasonURL: 'https://www.google.com/get/noto/' + }, + { + name: 'Jake Clark', + url: 'https://jake-clark.tumblr.com/', + reason: 'Image', + reasonURL: 'https://twitter.com/jakeclarkdude/status/689141113584619524' + } + ], + args: [ + { + key: 'first', + prompt: 'What should the text of the first button be?', + type: 'string', + max: 50 + }, + { + key: 'second', + prompt: 'What should the text of the second button be?', + type: 'string', + max: 50 + } + ] + }); + } + + async run(msg, { first, second }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'two-buttons.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.rotate(12 * (Math.PI / 180)); + ctx.font = '50px Noto'; + while (ctx.measureText(first).width > 183) { + fontSize -= 1; + ctx.font = `${fontSize}px Noto`; + } + const firstLines = await wrapText(ctx, first, 183); + ctx.fillText(firstLines.join('\n'), 126, 70); + ctx.font = '50px Noto'; + while (ctx.measureText(second).width > 122) { + fontSize -= 1; + ctx.font = `${fontSize}px Noto`; + } + const secondLines = await wrapText(ctx, second, 122); + ctx.fillText(secondLines.join('\n'), 355, 79); + ctx.rotate(-12 * (Math.PI / 180)); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'two-buttons.png' }] }); + } +}; diff --git a/package.json b/package.json index 1476f8ba..86a7b52b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.24.0", + "version": "114.25.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {