Spaces:
Paused
Paused
πππππππ πππππππ β‘
commited on
Create ai-fluxpro.js
Browse files- plugins/ai-fluxpro.js +64 -0
plugins/ai-fluxpro.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const config = require('../config');
|
| 2 |
+
const { cmd, commands } = require('../command');
|
| 3 |
+
const { fetchJson } = require('../lib/functions');
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
cmd({
|
| 7 |
+
pattern: "fluxpro",
|
| 8 |
+
alias: ["sdpro", "imaginepro"],
|
| 9 |
+
react: "",
|
| 10 |
+
desc: "Generate an image using AI.",
|
| 11 |
+
category: "main",
|
| 12 |
+
filename: __filename
|
| 13 |
+
}, async (conn, mek, m, {
|
| 14 |
+
from,
|
| 15 |
+
quoted,
|
| 16 |
+
body,
|
| 17 |
+
isCmd,
|
| 18 |
+
command,
|
| 19 |
+
args,
|
| 20 |
+
q,
|
| 21 |
+
isGroup,
|
| 22 |
+
sender,
|
| 23 |
+
senderNumber,
|
| 24 |
+
botNumber2,
|
| 25 |
+
botNumber,
|
| 26 |
+
pushname,
|
| 27 |
+
isMe,
|
| 28 |
+
isOwner,
|
| 29 |
+
groupMetadata,
|
| 30 |
+
groupName,
|
| 31 |
+
participants,
|
| 32 |
+
groupAdmins,
|
| 33 |
+
isBotAdmins,
|
| 34 |
+
isAdmins,
|
| 35 |
+
reply
|
| 36 |
+
}) => {
|
| 37 |
+
try {
|
| 38 |
+
if (!q) return reply("Please provide a prompt for the image.");
|
| 39 |
+
|
| 40 |
+
// Indicate processing of user request
|
| 41 |
+
await reply("> *Subzero Diffussing Your image...*");
|
| 42 |
+
|
| 43 |
+
// Generate and send requested image
|
| 44 |
+
let data = await fetchJson(`https://api.davidcyriltech.my.id/flux?prompt=${q}`);
|
| 45 |
+
|
| 46 |
+
// Check if data.result exists
|
| 47 |
+
if (!data || !data.result) {
|
| 48 |
+
throw new Error("Failed to generate image. Please try again later.");
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
const imageUrl = data.result;
|
| 52 |
+
|
| 53 |
+
// Send image with caption
|
| 54 |
+
await conn.sendMessage(m.chat, {
|
| 55 |
+
image: {
|
| 56 |
+
url: imageUrl,
|
| 57 |
+
caption: "Generated by Subzero"
|
| 58 |
+
}
|
| 59 |
+
});
|
| 60 |
+
} catch (error) {
|
| 61 |
+
console.error(error);
|
| 62 |
+
reply(`An error occurred: ${error.message}`);
|
| 63 |
+
}
|
| 64 |
+
});
|