Invert Command

This commit is contained in:
Daniel Odendahl Jr
2017-05-02 01:22:16 +00:00
parent 0db9be7c18
commit db412b8e09
2 changed files with 34 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
const { Command } = require('discord.js-commando');
const Jimp = require('jimp');
module.exports = class InvertCommand extends Command {
constructor(client) {
super(client, {
name: 'invert',
group: 'avataredit',
memberName: 'invert',
description: 'Invert your avatar colors.',
args: [{
key: 'user',
prompt: 'Which user would you like to edit the avatar of?',
type: 'user'
}]
});
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
const avatar = await Jimp.read(avatarURL);
avatar.invert();
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
});
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "17.1.4",
"version": "17.2.0",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {