diff --git a/assets/images/ugly.png b/assets/images/ugly.png new file mode 100644 index 00000000..5d6233ab Binary files /dev/null and b/assets/images/ugly.png differ diff --git a/commands/edit-meme/ugly.js b/commands/edit-meme/ugly.js new file mode 100644 index 00000000..b99485ff --- /dev/null +++ b/commands/edit-meme/ugly.js @@ -0,0 +1,54 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); +const { centerImagePart } = require('../../util/Canvas'); + +module.exports = class UglyCommand extends Command { + constructor(client) { + super(client, { + name: 'ugly', + aliases: ['uglier', 'uglier-up-close'], + group: 'edit-meme', + memberName: 'ugly', + description: 'Draws an image or a user\'s avatar over the "It\'s even uglier up close" meme.', + throttling: { + usages: 2, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Nickelodeon', + url: 'https://www.nick.com/', + reason: 'Original "Spongebob Squarepants" Show', + reasonURL: 'https://www.nick.com/shows/spongebob-squarepants' + } + ], + args: [ + { + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image-or-avatar', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 }) + } + ] + }); + } + + async run(msg, { image }) { + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'ugly.png')); + const { body } = await request.get(image); + const data = await loadImage(body); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + const { x, y, width, height } = centerImagePart(data, 170, 170, 120, 52); + ctx.drawImage(data, x, y, width, height); + ctx.drawImage(base, 0, 0); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ugly.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 42b595b0..076b6b07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "135.0.1", + "version": "135.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "private": true,