forked from Astaboi768/Ilom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt.js
More file actions
48 lines (43 loc) · 1.46 KB
/
prompt.js
File metadata and controls
48 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const axios = require('axios');
module.exports = {
config: {
name: "prompt",
version: "1.0",
author: "JARiF",
countDown: 0,
role: 0,
longDescription: {
vi: "",
en: "Get midjourney prompts."
},
category: "AI"
},
onStart: async function ({ message, event, args, api }) {
try {
const khankirChele = args.join(" ");
let imageUrl;
if (event.type === "message_reply") {
if (["photo", "sticker"].includes(event.messageReply.attachments[0]?.type)) {
imageUrl = event.messageReply.attachments[0].url;
} else {
return api.sendMessage({ body: "❌ | Reply must be an image." }, event.threadID);
}
} else if (args[0]?.match(/(https?:\/\/.*\.(?:png|jpg|jpeg))/g)) {
imageUrl = args[0];
} else if (!khankirChele) {
return api.sendMessage({ body: "❌ | Reply to an image or provide a prompt." }, event.threadID);
}
if (imageUrl) {
const response = await axios.get(`https://www.api.vyturex.com/describe?url=${encodeURIComponent(imageUrl)}`);
const description = response.data;
await message.reply(description);
} else if (khankirChele) {
const response = await axios.get(`https://www.api.vyturex.com/promptgen?content=${encodeURIComponent(khankirChele)}`);
const prompt = response.data;
await message.reply(prompt);
}
} catch (error) {
message.reply(`${error}`);
}
}
}