forked from Supositware/Haha-Yes
work with url and without
This commit is contained in:
parent
d65e6b89c5
commit
afeea173c3
1 changed files with 17 additions and 2 deletions
|
@ -9,6 +9,12 @@ module.exports = class faceappCommand extends Command {
|
||||||
memberName: 'face',
|
memberName: 'face',
|
||||||
description: `use faceapp to change the face of someone, Here the available filter https://goo.gl/5LLbJJ`,
|
description: `use faceapp to change the face of someone, Here the available filter https://goo.gl/5LLbJJ`,
|
||||||
args: [
|
args: [
|
||||||
|
{
|
||||||
|
key: 'url',
|
||||||
|
prompt: 'Wich image would you want to process',
|
||||||
|
type: 'string',
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'type',
|
key: 'type',
|
||||||
prompt: 'How the face should change ? (default to female)',
|
prompt: 'How the face should change ? (default to female)',
|
||||||
|
@ -20,12 +26,21 @@ module.exports = class faceappCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(message, { type }) {
|
async run(message, { url, type }) {
|
||||||
|
|
||||||
let Attachment = (message.attachments).array();
|
let Attachment = (message.attachments).array();
|
||||||
console.log(Attachment)
|
console.log(Attachment)
|
||||||
if(!Attachment[0]) {
|
if(!Attachment[0] && !url) {
|
||||||
return message.say("You need to send an image")
|
return message.say("You need to send an image")
|
||||||
|
} else if(url.includes("http") || url.includes("www")) {
|
||||||
|
let face = type.toLowerCase();
|
||||||
|
let { body } = await superagent.get(url)
|
||||||
|
let image = await faceapp.process(body, face)
|
||||||
|
.catch(error => {
|
||||||
|
message.say('Cant recognize the face')
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
message.channel.sendFile(image)
|
||||||
} else {
|
} else {
|
||||||
let face = type.toLowerCase();
|
let face = type.toLowerCase();
|
||||||
let { body } = await superagent.get(Attachment[0].url)
|
let { body } = await superagent.get(Attachment[0].url)
|
||||||
|
|
Loading…
Reference in a new issue