mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-10 07:03:08 -04:00
test in production
This commit is contained in:
parent
f6343191a6
commit
b3d7e2540d
2 changed files with 79 additions and 3 deletions
77
commands/message/genai/wallpaper.js
Normal file
77
commands/message/genai/wallpaper.js
Normal file
|
@ -0,0 +1,77 @@
|
|||
const { geminiVision, aiWallpaper } = require("../../../labscore/api/obelisk");
|
||||
const { getRecentImage } = require("../../../labscore/utils/attachment");
|
||||
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||
const { editOrReply } = require("../../../labscore/utils/message");
|
||||
const { getUser } = require("../../../labscore/utils/users");
|
||||
|
||||
const { Permissions } = require("detritus-client/lib/constants");
|
||||
|
||||
const { STATIC_ICONS } = require("../../../labscore/utils/statics");
|
||||
const { iconPill, stringwrap } = require("../../../labscore/utils/markdown");
|
||||
const { hasFeature } = require("../../../labscore/utils/testing");
|
||||
|
||||
module.exports = {
|
||||
name: 'wallpaper',
|
||||
label: 'text',
|
||||
aliases: ['aiwp'],
|
||||
metadata: {
|
||||
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nCreate Wallpapers`,
|
||||
description_short: 'Create Wallpapers',
|
||||
examples: ['aiwp northern lights'],
|
||||
category: 'limited',
|
||||
usage: 'aiwallpaper <prompt>'
|
||||
},
|
||||
args: [
|
||||
{ name: 'style', default: 'translucent', required: false, help: "Image 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/wallpapers")) return;
|
||||
context.triggerTyping();
|
||||
|
||||
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (prompt).`))
|
||||
|
||||
let input = args.text;
|
||||
|
||||
try{
|
||||
await editOrReply(context, createEmbed("defaultNoFooter", context, {
|
||||
author: {
|
||||
iconUrl: STATIC_ICONS.ai_image_processing,
|
||||
name: "Generating images..."
|
||||
}
|
||||
}))
|
||||
|
||||
let res = await aiWallpaper(context, args.text);
|
||||
|
||||
// Construct Embeds
|
||||
let files = [];
|
||||
let embeds = res.response.body.images.map((i)=>{
|
||||
let imgName = `lcwp.${(Date.now() + Math.random()).toString(36)}.jpeg`;
|
||||
|
||||
files.push({
|
||||
filename: imgName,
|
||||
value: Buffer.from(i, 'base64')
|
||||
})
|
||||
return createEmbed("defaultNoFooter", context, {
|
||||
url: "https://bignutty.gitlab.io",
|
||||
author: {
|
||||
iconUrl: STATIC_ICONS.ai_image,
|
||||
name: stringwrap(args.text, 50, false),
|
||||
},
|
||||
image: {
|
||||
url: `attachment://${imgName}`
|
||||
},
|
||||
footer: {
|
||||
text: `Generative AI is experimental • Use AI Images responsibly.`
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return editOrReply(context, {embeds, files});
|
||||
} 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 image.`))
|
||||
}
|
||||
}
|
||||
};
|
|
@ -96,10 +96,9 @@ module.exports.summarizeWebpage = async function(context, url){
|
|||
}
|
||||
|
||||
// ROBIN
|
||||
module.exports.aiWallpaper = async function(context, prompt, style){
|
||||
module.exports.aiWallpaper = async function(context, prompt){
|
||||
return await request(ObeliskApi.AI_WALLPAPER, "POST", {}, {
|
||||
prompt,
|
||||
style
|
||||
prompt
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue