// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs"); const path = require("path"); const mahmud = async () => { const response = await axios.get("https://raw.githubusercontent.com/mahmudx7/HINATA/main/baseApiUrl.json"); return response.data.mahmud; }; /** * @author MahMUD * @author: do not delete it */ module.exports = { config: { name: "flowers", version: "1.7", role: 0, author: "MahMUD", category: "Media", guide: { en: "Use {pn} to get a random Flower video." } }, onStart: async function ({ api, event, message }) { try { const loadingMessage = await message.reply("๐Ÿค | ๐—Ÿ๐—ผ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด ๐—ฟ๐—ฎ๐—ป๐—ฑ๐—ผ๐—บ ๐—™๐—น๐—ผ๐˜„๐—ฒ๐—ฟ...๐—ฃ๐—น๐—ฒ๐—ฎ๐˜€๐—ฒ ๐˜„๐—ฎ๐—ถ๐˜..!!"); setTimeout(() => { api.unsendMessage(loadingMessage.messageID); }, 5000); const apiUrl = await mahmud(); const res = await axios.get(`${apiUrl}/api/album/mahmud/videos/flower?userID=${event.senderID}`); if (!res.data.success || !res.data.videos.length) return api.sendMessage("โŒ | No videos found.", event.threadID, event.messageID); const url = res.data.videos[Math.floor(Math.random() * res.data.videos.length)]; const filePath = path.join(__dirname, "temp_video.mp4"); const video = await axios({ url, method: "GET", responseType: "stream", headers: { 'User-Agent': 'Mozilla/5.0' } }); const writer = fs.createWriteStream(filePath); video.data.pipe(writer); writer.on("finish", () => { api.sendMessage({ body: "โœจ | ๐‡๐ž๐ซ๐ž'๐ฌ ๐ฒ๐จ๐ฎ๐ซ ๐…๐ฅ๐จ๐ฐ๐ž๐ซ ๐ฏ๐ข๐๐ž๐จ", attachment: fs.createReadStream(filePath) }, event.threadID, () => fs.unlinkSync(filePath), event.messageID); }); writer.on("error", () => { api.sendMessage("โŒ | Download error.", event.threadID, event.messageID); }); } catch (e) { console.error("ERROR:", e); api.sendMessage("๐Ÿฅนerror, contact Kakashi.", event.threadID, event.messageID); } } };