const axios = require("axios"); function extractAllUrls(obj, result = []) { if (!obj) return result; if (typeof obj === "string") { const urls = obj.match(/(https?:\/\/[^\s]+)/g); if (urls) result.push(...urls); } else if (Array.isArray(obj)) { for (const item of obj) extractAllUrls(item, result); } else if (typeof obj === "object") { for (const key in obj) { extractAllUrls(obj[key], result); } } return result; } module.exports = { config: { name: "drive", aliases: [" "], version: "0.2", author: "Arafat", countDown: 5, role: 0, category: "UTILITY", guide: { en: "{pn} reply to a message that contains a media file (or a link to one)" } }, onStart: async function ({ api, event, args, message }) { try { if (!event.messageReply) { return message.reply("āŒ | šš„šžššš¬šž š«šžš©š„š² š­šØ šš š¦šžš¬š¬ššš šž š°š¢š­š” šš š¦šžšš¢šš šŸš¢š„šž šØš« š”š‘š‹."); } const allUrls = extractAllUrls(event.messageReply); const uniqueUrls = [...new Set(allUrls)]; if (uniqueUrls.length === 0) { return message.reply("āŒ | ššØ š”š‘š‹ šŸšØš®š§š š¢š§ š­š”šž š«šžš©š„š¢šžš š¦šžš¬š¬ššš šž. šš„šžššš¬šž š«šžš©š„š² š­šØ šš š¦šžš¬š¬ššš šž š°š¢š­š” šš š¦šžšš¢šš šŸš¢š„šž."); } const fileUrl = uniqueUrls[0]; const waitMsg = await message.reply("ā³ | š”š©š„šØšššš¢š§š  š­šØ šš«š¢šÆšž..."); const res = await axios.post( "https://driver-public-by-arafat.vercel.app/api/upload", { url: fileUrl }, { headers: { "Content-Type": "application/json" } } ); if (!res.data || !res.data.downloadUrl) { throw new Error("Upload failed"); } await api.unsendMessage(waitMsg.messageID); return message.reply( `āœ… šƒš«š¢šÆšž š”š©š„šØššš š’š®šœšœšžš¬š¬šŸš®š„\n\nšŸ”— šƒšØš°š§š„šØššš š‹š¢š§š¤:\n${res.data.downloadUrl}` ); } catch (err) { return message.reply("āŒ | š„š«š«šØš«: " + err.message); } } };