mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 21:53:07 -04:00
emogen
This commit is contained in:
parent
a644ef6e31
commit
87438da5f4
3 changed files with 63 additions and 0 deletions
54
commands/message/genai/emogen.js
Normal file
54
commands/message/genai/emogen.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
const { emogen } = require("#api");
|
||||||
|
|
||||||
|
const { createEmbed } = require("#utils/embed");
|
||||||
|
const { iconPill } = require("#utils/markdown");
|
||||||
|
const { editOrReply } = require("#utils/message");
|
||||||
|
const { hasFeature } = require("#utils/testing");
|
||||||
|
|
||||||
|
// TODO: Turn this into a general purpose permissions constant
|
||||||
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'emogen',
|
||||||
|
label: 'text',
|
||||||
|
metadata: {
|
||||||
|
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nEmogen`,
|
||||||
|
description_short: 'Emogen',
|
||||||
|
examples: ['emogen otter eating a slice of pizza'],
|
||||||
|
category: 'limited',
|
||||||
|
usage: 'emogen <prompt>'
|
||||||
|
},
|
||||||
|
args: [
|
||||||
|
{ name: 'style', default: 'microsoft', required: false, help: "Emogen Style" }
|
||||||
|
],
|
||||||
|
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.ATTACH_FILES, Permissions.READ_MESSAGE_HISTORY],
|
||||||
|
run: async (context, args) => {
|
||||||
|
if(!await hasFeature(context, "ai/imagen")) return;
|
||||||
|
context.triggerTyping();
|
||||||
|
|
||||||
|
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (prompt).`))
|
||||||
|
|
||||||
|
try{
|
||||||
|
await editOrReply(context, createEmbed("loading", context, "Generating emoji..."));
|
||||||
|
|
||||||
|
let res = await emogen(context, args.text, args.style)
|
||||||
|
|
||||||
|
let file = `emogen.${Date.now()}.png`;
|
||||||
|
|
||||||
|
return editOrReply(context, {
|
||||||
|
embeds: [
|
||||||
|
createEmbed("image", context, {
|
||||||
|
url: file
|
||||||
|
})
|
||||||
|
],
|
||||||
|
files: [{
|
||||||
|
filename: file,
|
||||||
|
value: res.response.body
|
||||||
|
}]});
|
||||||
|
} catch(e){
|
||||||
|
console.log(e)
|
||||||
|
if(e.response?.body?.message) return editOrReply(context, createEmbed("error", context, e.response.body.message))
|
||||||
|
return editOrReply(context, createEmbed("error", context, `Unable to generate emoji.`))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -26,6 +26,8 @@ const Api = Object.freeze({
|
||||||
IMAGE_TEXT2IMAGE: '/image/deepai/text2image',
|
IMAGE_TEXT2IMAGE: '/image/deepai/text2image',
|
||||||
IMAGE_WAIFU2X: '/image/deepai/waifu2x',
|
IMAGE_WAIFU2X: '/image/deepai/waifu2x',
|
||||||
|
|
||||||
|
IMAGE_EMOGEN: '/image/emogen/generate',
|
||||||
|
|
||||||
PHOTOFUNIA_RETRO_WAVE: '/photofunia/retro-wave',
|
PHOTOFUNIA_RETRO_WAVE: '/photofunia/retro-wave',
|
||||||
PHOTOFUNIA_YACHT: '/photofunia/yacht',
|
PHOTOFUNIA_YACHT: '/photofunia/yacht',
|
||||||
|
|
||||||
|
|
|
@ -272,6 +272,13 @@ module.exports.text2image = async function(context, text){
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.emogen = async function(context, prompt, style){
|
||||||
|
return await request(Api.IMAGE_EMOGEN, "GET", {}, {
|
||||||
|
prompt,
|
||||||
|
style
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.imtranslator = async function(context, text, voice){
|
module.exports.imtranslator = async function(context, text, voice){
|
||||||
return await request(Api.TTS_IMTRANSLATOR, "GET", {}, {
|
return await request(Api.TTS_IMTRANSLATOR, "GET", {}, {
|
||||||
text: text,
|
text: text,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue