Botpack / modules /commands /geminipro.js
Jonell01's picture
Upload 64 files
2821330 verified
module.exports.config = {
name: "geminipro",
hasPermission: 0,
version: "1.0.0",
commandCategory: "Media",
description: "Generate captions using Claude Vision API.",
usePrefix: true,
credits: "Jonell Magallanes",
cooldowns: 10
};
module.exports.run = async function ({ api, event, args }) {
try {
if (!args[0]) {
return api.sendMessage(`❌ Please provide a prompt!`, event.threadID, event.messageID);
}
if (event.type !== "message_reply" || !event.messageReply.attachments || event.messageReply.attachments.length === 0) {
return api.sendMessage(
`❌ Please reply to a message containing an image attachment.`,
event.threadID,
event.messageID
);
}
api.sendMessage("πŸ€” Thinking...", event.threadID, async () => {
const message = args.join(" ");
const imageURL = event.messageReply.attachments[0].url;
const apiUrl = `https://hazzey-api.vercel.app/claude-vision?message=${encodeURIComponent(message)}&image_url=${encodeURIComponent(imageURL)}`;
const axios = require("axios");
try {
const response = await axios.get(apiUrl);
if (response.data && response.data.content && response.data.content.length > 0) {
const caption = response.data.content[0].text;
return api.sendMessage(`βœ… Generated Caption: ${caption}`, event.threadID, event.messageID);
} else {
return api.sendMessage(`⚠️ No valid response received from the API.`, event.threadID, event.messageID);
}
} catch (error) {
console.error(error);
return api.sendMessage(
`❌ An error occurred while processing your request: ${error.message}`,
event.threadID,
event.messageID
);
}
});
} catch (error) {
console.error(error);
return api.sendMessage(
`❌ An error occurred while processing your request: ${error.message}`,
event.threadID,
event.messageID
);
}
};