diff --git a/README.md b/README.md index d3058497..723f3395 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 523 +Total: 524 ### Utility: @@ -696,6 +696,7 @@ Total: 523 * **like:** Sends an "Everyone Liked That" meme with the image of your choice. * **lisa-presentation:** Sends a "Lisa Presentation" meme with the presentation of your choice. * **look-at-this-photograph:** Draws an image or a user's avatar over Nickelback's photograph. +* **mario-bros-views:** Sends a "Mario Bros. Views" meme with the text of your choice. * **meme-gen-classic:** Sends a meme with the text and background of your choice. * **meme-gen-modern:** Sends a meme with the text and image of your choice. * **my-collection-grows:** Sends a "My collection grows richer" Nekopara meme with the text of your choice. @@ -1088,6 +1089,7 @@ here. * illegal ([Noto Font](https://www.google.com/get/noto/)) * lisa-presentation ([Noto Font](https://www.google.com/get/noto/)) * map ([Maps Static API](https://developers.google.com/maps/documentation/maps-static/intro)) + * mario-bros-views ([Noto Font](https://www.google.com/get/noto/)) * meme-gen-modern ([Noto Font](https://www.google.com/get/noto/)) * new-password ([Noto Font](https://www.google.com/get/noto/)) * nike-ad ([Noto Font](https://www.google.com/get/noto/)) @@ -1347,6 +1349,7 @@ here. * nike-ad (Logo, Concept) - [Nintendo](https://www.nintendo.com/) * challenger ([Original "Super Smash Bros." Game](https://www.smashbros.com/en_US/index.html)) + * mario-bros-views ([Original "Super Mario Bros." Game](https://mario.nintendo.com/)) * smw-level ([Original "Super Mario World" Game](https://www.nintendo.co.jp/n02/shvc/mw/index.html)) - [NotAWeebDev](https://github.com/NotAWeebDev/) * triggered ([Image](https://github.com/NotAWeebDev/Misaki/blob/2e44f9efb467028dcbae5a2c9f836d2e99860b85/assets/images/plate_triggered.png)) @@ -1380,6 +1383,7 @@ here. * i-fear-no-man (Concept) * if-those-kids-could-read (Concept) * like (Concept) + * mario-bros-views (Concept) * pills (Concept) * pogchamp (Concept) * porn (Original Subreddit List) diff --git a/commands/edit-meme/mario-bros-views.js b/commands/edit-meme/mario-bros-views.js new file mode 100644 index 00000000..82ea4798 --- /dev/null +++ b/commands/edit-meme/mario-bros-views.js @@ -0,0 +1,107 @@ +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 MarioBrosViewsCommand extends Command { + constructor(client) { + super(client, { + name: 'mario-bros-views', + aliases: ['mario-views', 'luigi-views', 'mario-luigi-views', 'mario-says', 'luigi-says'], + group: 'edit-meme', + memberName: 'mario-bros-views', + description: 'Sends a "Mario Bros. Views" meme with the text of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Nintendo', + url: 'https://www.nintendo.com/', + reason: 'Original "Super Mario Bros." Game', + reasonURL: 'https://mario.nintendo.com/' + }, + { + name: 'Google', + url: 'https://www.google.com/', + reason: 'Noto Font', + reasonURL: 'https://www.google.com/get/noto/' + }, + { + name: 'Overtime2005', + url: 'https://github.com/Overtime2005', + reason: 'Concept' + } + ], + args: [ + { + key: 'thing', + prompt: 'What do you want the Mario Bros. to tell their views on?', + type: 'string', + max: 20 + }, + { + key: 'mario', + prompt: 'What should Mario\'s views be?', + type: 'string', + max: 280 + }, + { + key: 'luigi', + prompt: 'What should Luigi\'s views be?', + type: 'string', + max: 280 + } + ] + }); + } + + async run(msg, { thing, mario, luigi }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'mario-bros-views.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.textBaseline = 'top'; + ctx.textAlign = 'center'; + ctx.font = '47px Noto'; + ctx.fillText(thing, 420, 108, 180); + ctx.textAlign = 'start'; + ctx.fillStyle = 'white'; + ctx.font = '36px Noto'; + let fontSize = 36; + while (ctx.measureText(mario).width > 765) { + fontSize--; + ctx.font = `${fontSize}px Noto`; + } + const marioLines = await wrapText(ctx, text, 381); + const marioTopMost = 450 - (((fontSize * marioLines.length) / 2) + ((20 * (marioLines.length - 1)) / 2)); + for (let i = 0; i < marioLines.length; i++) { + ctx.strokeStyle = 'black'; + ctx.lineWidth = 5; + const height = marioTopMost + ((fontSize + 20) * i); + ctx.strokeText(marioLines[i], 235, height); + ctx.fillText(marioLines[i], 235, height); + } + ctx.font = '36px Noto'; + fontSize = 36; + while (ctx.measureText(luigi).width > 765) { + fontSize--; + ctx.font = `${fontSize}px Noto`; + } + const luigiLines = await wrapText(ctx, text, 381); + const luigiTopMost = 450 - (((fontSize * luigiLines.length) / 2) + ((20 * (luigiLines.length - 1)) / 2)); + for (let i = 0; i < luigiLines.length; i++) { + ctx.strokeStyle = 'black'; + ctx.lineWidth = 5; + const height = luigiTopMost + ((fontSize + 20) * i); + ctx.strokeText(luigiLines[i], 420, height); + ctx.fillText(luigiLines[i], 420, height); + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'mario-bros-views.png' }] }); + } +}; diff --git a/package.json b/package.json index 808832ac..40d597c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.5.1", + "version": "119.6.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {