mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 21:53:07 -04:00
editimage command
This commit is contained in:
parent
3d6233a0a7
commit
f35586fe89
7 changed files with 51 additions and 4 deletions
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
}))
|
}))
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to modify image.`)]})
|
return editOrReply(context, {embeds:[createEmbed("error", context, `Deepdream timed out.`)]})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
39
commands/message/image/deepai/imageedit.js
Normal file
39
commands/message/image/deepai/imageedit.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
const { getRecentImage } = require("../../../../labscore/utils/attachment");
|
||||||
|
const { createEmbed } = require("../../../../labscore/utils/embed");
|
||||||
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
||||||
|
|
||||||
|
const { deepdream, imageedit } = require('../../../../labscore/api')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'editimage',
|
||||||
|
aliases: ['ei'],
|
||||||
|
label: 'prompt',
|
||||||
|
metadata: {
|
||||||
|
description: 'Edits an image using AI.',
|
||||||
|
description_short: 'AI image editing',
|
||||||
|
examples: ['editimage With a crown'],
|
||||||
|
category: 'image',
|
||||||
|
usage: 'editimage <prompt>'
|
||||||
|
},
|
||||||
|
run: async (context, args) => {
|
||||||
|
context.triggerTyping();
|
||||||
|
try{
|
||||||
|
if(!args.prompt) return editOrReply(context, { embeds: [createEmbed("warning", context, "Missing prompt.")] })
|
||||||
|
|
||||||
|
let image = await getRecentImage(context, 50)
|
||||||
|
if(!image) return editOrReply(context, { embeds: [createEmbed("warning", context, "No images found.")] })
|
||||||
|
|
||||||
|
let res = await imageedit(context, image, args.prompt)
|
||||||
|
|
||||||
|
if(res.response.body.status == 1) return editOrReply(context, {embeds:[createEmbed("warning", context, res.response.body.errors[0])]})
|
||||||
|
|
||||||
|
return editOrReply(context, createEmbed("image", context, {
|
||||||
|
url: res.response.body.image,
|
||||||
|
time: res.timings
|
||||||
|
}))
|
||||||
|
}catch(e){
|
||||||
|
console.log(e)
|
||||||
|
return editOrReply(context, {embeds:[createEmbed("error", context, `Image editing timed out.`)]})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
}))
|
}))
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to modify image.`)]})
|
return editOrReply(context, {embeds:[createEmbed("error", context, `Superresolution timed out.`)]})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
}))
|
}))
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to generate image.`)]})
|
return editOrReply(context, {embeds:[createEmbed("error", context, `Text2image timed out.`)]})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
}))
|
}))
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to modify image.`)]})
|
return editOrReply(context, {embeds:[createEmbed("error", context, `Waifu2x timed out.`)]})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -17,6 +17,7 @@ const Api = Object.freeze({
|
||||||
GOOGLE_VISION_WEBDETECTION: '/google/vision/webdetection',
|
GOOGLE_VISION_WEBDETECTION: '/google/vision/webdetection',
|
||||||
|
|
||||||
IMAGE_DEEPDREAM: '/image/deepai/deepdream',
|
IMAGE_DEEPDREAM: '/image/deepai/deepdream',
|
||||||
|
IMAGE_IMAGEEDITOR: '/image/deepai/imageedit',
|
||||||
IMAGE_SUPERRESOLUTION: '/image/deepai/superresolution',
|
IMAGE_SUPERRESOLUTION: '/image/deepai/superresolution',
|
||||||
IMAGE_TEXT2IMAGE: '/image/deepai/text2image',
|
IMAGE_TEXT2IMAGE: '/image/deepai/text2image',
|
||||||
IMAGE_WAIFU2X: '/image/deepai/waifu2x',
|
IMAGE_WAIFU2X: '/image/deepai/waifu2x',
|
||||||
|
|
|
@ -222,6 +222,13 @@ module.exports.deepdream = async function(context, url){
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.imageedit = async function(context, url, prompt){
|
||||||
|
return await request(Api.IMAGE_IMAGEEDITOR, "GET", {}, {
|
||||||
|
url: url,
|
||||||
|
prompt: prompt
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.waifu2x = async function(context, url){
|
module.exports.waifu2x = async function(context, url){
|
||||||
return await request(Api.IMAGE_WAIFU2X, "GET", {}, {
|
return await request(Api.IMAGE_WAIFU2X, "GET", {}, {
|
||||||
url: url
|
url: url
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue