const axios = require("axios"); const fs = require("fs"); const path = require("path"); module.exports = { config: { name: "islamicvideo", aliases: ["islamicvd"], version: "3.1", author: "NC-AZAD", role: 0, shortDescription: "Send a random Islamic video", category: "Islamic", guide: { en: "{pn}" } }, onStart: async function({ message, api, event }) { let loadingID; try { const loadingMsg = await message.reply("ā³ š—Ÿš—¼š—®š—±š—¶š—»š—“ š—¬š—¼š˜‚š—æ š—œš˜€š—¹š—®š—ŗš—¶š—° š—©š—¶š—±š—²š—¼..."); loadingID = loadingMsg.messageID; const RAW_URL = "https://raw.githubusercontent.com/noobcore404/NC-STORE/main/NCApiUrl.json"; const rawRes = await axios.get(RAW_URL, { timeout: 15000 }); const rawData = typeof rawRes.data === "string" ? JSON.parse(rawRes.data) : rawRes.data; const BASE_API = rawData.islamic; if (!BASE_API) throw new Error("Base API not found in RAW"); const apiUrl = `${BASE_API}/api/video`; const { data } = await axios.get(apiUrl, { timeout: 15000 }); if (!data?.info) throw new Error("No video URL returned"); const videoUrl = data.info; const filePath = path.join(__dirname, `islamic_${Date.now()}.mp4`); const writer = fs.createWriteStream(filePath); const response = await axios({ url: videoUrl, method: "GET", responseType: "stream" }); response.data.pipe(writer); writer.on("finish", async () => { await message.reply({ body: "šŸŒ™šŸ“– š—¬š—¼š˜‚š—æ š—œš˜€š—¹š—®š—ŗš—¶š—° š—©š—¶š—±š—²š—¼ 🌸✨", attachment: fs.createReadStream(filePath) }); fs.unlinkSync(filePath); if (loadingID) await api.unsendMessage(loadingID); }); writer.on("error", async () => { if (loadingID) await api.unsendMessage(loadingID); message.reply("āŒ š—˜š—æš—æš—¼š—æ š—±š—¼š˜„š—»š—¹š—¼š—®š—±š—¶š—»š—“ š—©š—¶š—±š—²š—¼!"); }); } catch (err) { console.error("IslamicVideo Error:", err.message); if (loadingID) await api.unsendMessage(loadingID); message.reply("āŒ š—©š—¶š—±š—²š—¼ š—Ÿš—¼š—®š—± š—™š—®š—¶š—¹š—²š—±\nšŸ” š—£š—¹š—²š—®š˜€š—² š—§š—æš˜† š—”š—“š—®š—¶š—»"); } } };