const axios = require("axios"); const API_BASE = "https://hridoy-api.onrender.com"; module.exports = { config: { name: "imgbb", aliases: ["ibb","imb"], version: "2.0", author: "HR ID OY", countDown: 5, role: 0, shortDescription: "Upload image/gif to ImgBB", category: "AI", guide: "{pn} [reply to image/gif]" }, onStart: async function ({ api, event }) { const { threadID, messageID, type, messageReply } = event; if (type !== "message_reply" || !messageReply?.attachments?.[0]) return api.sendMessage("Please reply to an image or gif!", threadID, messageID); const attachment = messageReply.attachments[0]; if (attachment.type !== "photo" && attachment.type !== "animated_image") return api.sendMessage("Please reply to an image or gif!", threadID, messageID); const fileUrl = attachment.url; const waitMsg = await api.sendMessage("Uploading...", threadID, messageID); try { const config = (await axios.get(`${API_BASE}/api/links/imgbb`)).data; const res = await axios.get(`${config.url}?${config.queryParam}=${encodeURIComponent(fileUrl)}`); if (!res.data.status) throw new Error("Upload failed"); const keys = config.responseKey.split("."); const result = keys.reduce((obj, key) => obj?.[key], res.data); return api.editMessage(result, waitMsg.messageID); } catch (err) { return api.editMessage("Failed to upload!", waitMsg.messageID); } } };