Files
xiao/commands/avataredit/rip.js
T
Daniel Odendahl Jr 76907549df The Power of const
2017-04-03 22:31:19 +00:00

45 lines
1.6 KiB
JavaScript

const commando = require('discord.js-commando');
const Jimp = require("jimp");
module.exports = class RIPCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'rip',
aliases: [
'grave',
'gravestone'
],
group: 'avataredit',
memberName: 'rip',
description: 'Puts a profile picture over a gravestone. (;rip @User)',
examples: [';rip @User'],
args: [{
key: 'user',
prompt: 'Which user would you like to edit the avatar of?',
type: 'user'
}]
});
}
async run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return;
}
console.log(`[Command] ${message.content}`);
const user = args.user;
let userAvatar = user.displayAvatarURL;
userAvatar = userAvatar.replace(".jpg", ".png");
userAvatar = userAvatar.replace(".gif", ".png");
let images = [];
images.push(Jimp.read(userAvatar));
images.push(Jimp.read("./images/gravestone.jpg"));
const [avatar, gravestone] = await Promise.all(images);
avatar.resize(200, 200);
gravestone.blit(avatar, 60, 65);
gravestone.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return message.say(':x: Error! Something went wrong!');
return message.channel.sendFile(buff);
});
}
};