diff --git a/README.md b/README.md index 3e5cac41..35200ef4 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 522 +Total: 523 ### Utility: @@ -683,6 +683,7 @@ Total: 522 * **distracted-boyfriend:** Draws three user's avatars over the "Distracted Boyfriend" meme. * **drakeposting:** Sends a "Drakeposting" meme with the text of your choice. * **edd-facts-book:** Sends a "Double D's Facts Book" meme with the fact of your choice. +* **enslaved:** Sends a "Ah yes, enslaved" meme with the image and text of your choice. * **food-broke:** Draws a user's avatar over the "Food Broke" meme. * **for-five-hours:** Sends an "I've looked at this for 5 hours now" meme with the image of your choice. * **genie-rules:** Sends a "There are 4 rules" meme with the text of your choice. @@ -1076,6 +1077,7 @@ here. * demotivational ([Noto Font](https://www.google.com/get/noto/)) * drakeposting ([Noto Font](https://www.google.com/get/noto/)) * edd-facts-book ([Noto Font](https://www.google.com/get/noto/)) + * enslaved ([Noto Font](https://www.google.com/get/noto/)) * genie-rules ([Noto Font](https://www.google.com/get/noto/)) * google ([Custom Search API](https://cse.google.com/cse/all)) * google-autofill (Autofill API) @@ -1370,6 +1372,7 @@ here. * alert (Concept) * boardroom-meeting (Concept) * dislike (Concept) + * enslaved (Concept) * for-five-hours (Concept) * gun (Concept) * hands (Concept) diff --git a/assets/images/enslaved.png b/assets/images/enslaved.png new file mode 100644 index 00000000..896296c3 Binary files /dev/null and b/assets/images/enslaved.png differ diff --git a/commands/edit-meme/enslaved.js b/commands/edit-meme/enslaved.js new file mode 100644 index 00000000..4c9d57d3 --- /dev/null +++ b/commands/edit-meme/enslaved.js @@ -0,0 +1,73 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); +const { centerImagePart } = 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 EnslavedCommand extends Command { + constructor(client) { + super(client, { + name: 'enslaved', + aliases: ['ah-yes-enslaved', 'ah-yes'], + group: 'edit-meme', + memberName: 'enslaved', + description: 'Sends a "Ah yes, enslaved" meme with the image and text 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: 'Overtime2005', + url: 'https://github.com/Overtime2005', + reason: 'Concept' + } + ], + args: [ + { + key: 'name', + prompt: 'What is the name of thing you want to enslave?', + type: 'string', + max: 20 + }, + { + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 }) + } + ] + }); + } + + async run(msg, { name, image }) { + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'enslaved.png')); + const { body } = await request.get(image); + const data = await loadImage(body); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + const { x, y, width, height } = centerImagePart(data, 200, 200, 254, 145); + ctx.drawImage(data, x, y, width, height); + ctx.textBaseline = 'top'; + ctx.textAlign = 'center'; + ctx.fillStyle = 'white'; + ctx.font = '50px Noto'; + ctx.fillText(name.toLowerCase(), 365, 400, 240); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'enslaved.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 4580d0b9..5ed6c8fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.4.2", + "version": "119.5.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {