diff --git a/assets/images/the-ultimate-tattoo.png b/assets/images/the-ultimate-tattoo.png new file mode 100644 index 00000000..675589b0 Binary files /dev/null and b/assets/images/the-ultimate-tattoo.png differ diff --git a/commands/avatar-edit/the-ultimate-tattoo.js b/commands/avatar-edit/the-ultimate-tattoo.js new file mode 100644 index 00000000..1bdb912c --- /dev/null +++ b/commands/avatar-edit/the-ultimate-tattoo.js @@ -0,0 +1,47 @@ +const { Command } = require('discord.js-commando'); +const { createCanvas, loadImage } = require('canvas'); +const snekfetch = require('snekfetch'); +const path = require('path'); + +module.exports = class TheUltimateTattooCommand extends Command { + constructor(client) { + super(client, { + name: 'the-ultimate-tattoo', + aliases: ['ultimate-tattoo', 'tattoo'], + group: 'avatar-edit', + memberName: 'the-ultimate-tattoo', + description: 'Draws a user\'s avatar as "The Ultimate Tattoo".', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'user', + prompt: 'Which user would you like to edit the avatar of?', + type: 'user', + default: msg => msg.author + } + ] + }); + } + + async run(msg, { user }) { + const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 }); + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'the-ultimate-tattoo.png')); + const { body } = await snekfetch.get(avatarURL); + const avatar = await loadImage(body); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.rotate(-10 * (Math.PI / 180)); + ctx.drawImage(avatar, 184, 687, 300, 300); + ctx.rotate(10 * (Math.PI / 180)); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'the-ultimate-tattoo.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 6ba7a3bf..0951e520 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "61.0.1", + "version": "61.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {