Look What Karen Have

This commit is contained in:
Daniel Odendahl Jr
2017-11-02 02:47:35 +00:00
parent 1a6853df98
commit 79ccfa0341
3 changed files with 54 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

@@ -0,0 +1,53 @@
const { Command } = require('discord.js-commando');
const { createCanvas, loadImage } = require('canvas');
const snekfetch = require('snekfetch');
const path = require('path');
module.exports = class LookWhatKarenHaveCommand extends Command {
constructor(client) {
super(client, {
name: 'look-what-karen-have',
aliases: ['look-at-what-karen-has', 'look-what-karen-has'],
group: 'avatar-edit',
memberName: 'look-what-karen-have',
description: 'Draws a user\'s avatar over Karen\'s photo.',
throttling: {
usages: 1,
duration: 15
},
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'user',
prompt: 'Which user would you like to edit the avatar of?',
type: 'user',
default: ''
}
]
});
}
async run(msg, { user }) {
if (!user) user = msg.author;
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 512
});
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'look-what-karen-have.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.fillStyle = 'white';
ctx.fillRect(0, 0, base.width, base.height);
ctx.rotate(-6.5 * (Math.PI / 180));
ctx.drawImage(avatar, 517, 8, 512, 512);
ctx.rotate(-6.5 * (Math.PI / 180));
ctx.drawImage(base, 0, 0);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'look-what-karen-have.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "51.2.2",
"version": "51.3.0",
"description": "Your personal server companion.",
"main": "XiaoBot.js",
"scripts": {