Haha-Yes/commands/fun/face.js

40 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-10-10 15:37:03 +02:00
const { Command } = require('discord.js-commando');
const faceapp = require('faceapp')
const superagent = require('superagent')
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: [
{
key: 'url',
prompt: 'Wich image would you want to process',
type: 'string',
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-10 15:37:03 +02:00
}
]
});
}
2018-10-10 15:46:00 +02:00
async run(message, { url, type }) {
2018-10-12 15:41:25 +02:00
var Attachment = (message.attachments).array();
2018-10-10 16:00:17 +02:00
let face = type.toLowerCase();
2018-10-12 15:41:25 +02:00
let { body } = await superagent.get(Attachment[0].url)
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-10 15:37:03 +02:00
message.channel.sendFile(image)
2018-10-12 15:41:25 +02:00
}};