2018-10-10 15:37:03 +02:00
|
|
|
const { Command } = require('discord.js-commando');
|
|
|
|
const faceapp = require('faceapp')
|
|
|
|
const superagent = require('superagent')
|
2018-10-15 20:23:45 +02:00
|
|
|
const blacklist = require('../../json/blacklist.json')
|
|
|
|
|
2018-10-10 15:37:03 +02:00
|
|
|
module.exports = class faceappCommand extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
|
|
name: 'face',
|
|
|
|
group: 'fun',
|
|
|
|
memberName: 'face',
|
|
|
|
description: `use faceapp to change the face of someone, Here the available filter https://goo.gl/5LLbJJ`,
|
|
|
|
args: [
|
2018-10-10 15:46:00 +02:00
|
|
|
{
|
|
|
|
key: 'type',
|
2018-10-11 13:08:30 +02:00
|
|
|
prompt: 'How the face should change ? (default to female)',
|
2018-10-10 15:46:00 +02:00
|
|
|
type: 'string',
|
2018-10-11 15:37:03 +02:00
|
|
|
default: 'female',
|
2018-10-11 13:08:30 +02:00
|
|
|
oneOf: ["no-filter", "smile", "smile_2", "hot", "old", "young", "hollywood", "fun_glasses", "hitman", "mustache_free", "pan", "heisenberg", "female", "female_2", "male", "impression", "goatee", "mustache", "hipster", "lion", "bangs", "glasses", "wave", "makeup"]
|
2018-10-12 16:16:14 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'url',
|
|
|
|
prompt: 'Wich image would you want to process (default to empty so you can also send an image without the adress)',
|
|
|
|
type: 'string',
|
|
|
|
default: ''
|
2018-10-10 15:37:03 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-10-12 16:09:29 +02:00
|
|
|
async run(message, { url, type }) {
|
2018-10-15 20:23:45 +02:00
|
|
|
if(blacklist[message.author.id])
|
|
|
|
return message.channel.send("You are blacklisted")
|
2018-10-12 15:41:25 +02:00
|
|
|
|
2018-10-12 15:42:27 +02:00
|
|
|
let Attachment = (message.attachments).array();
|
2018-10-13 01:17:07 +02:00
|
|
|
let origin = null;
|
2018-10-12 16:09:29 +02:00
|
|
|
if(!Attachment[0] && !url) {
|
2018-10-12 15:45:28 +02:00
|
|
|
return message.say("You need to send an image")
|
2018-10-12 16:09:29 +02:00
|
|
|
} else if(url.includes("http") || url.includes("www")) {
|
2018-10-13 01:17:07 +02:00
|
|
|
origin = url;
|
|
|
|
} else
|
|
|
|
origin = Attachment[0].url
|
|
|
|
|
2018-10-12 16:09:29 +02:00
|
|
|
let face = type.toLowerCase();
|
2018-10-13 01:17:07 +02:00
|
|
|
let { body } = await superagent.get(origin)
|
2018-10-10 16:00:17 +02:00
|
|
|
let image = await faceapp.process(body, face)
|
2018-10-11 15:43:43 +02:00
|
|
|
.catch(error => {
|
|
|
|
message.say('Cant recognize the face')
|
|
|
|
console.error(error)
|
|
|
|
})
|
2018-10-13 01:12:20 +02:00
|
|
|
return message.channel.send({files: [image]});
|
2018-10-12 15:41:25 +02:00
|
|
|
}};
|