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; }; module.exports = { config: { name: "onepiece", aliases: ["onepiecevid", "onep", "onepvideo"], version: "1.7", role: 0, author: "MahMUD", category: "Media", guide: { en: "Use {pn} to get a random onepiece video." } }, onStart: async function ({ api, event }) { const obfuscatedAuthor = String.fromCharCode(77, 97, 104, 77, 85, 68); if (module.exports.config.author !== obfuscatedAuthor) { return api.sendMessage("You are not authorized to change the author name.", event.threadID, event.messageID); } try { const apiUrl = await mahmud(); const res = await axios.get(`${apiUrl}/api/album/mahmud/videos/onepiece?userID=${event.senderID}`); if (!res.data.success || !res.data.videos.length) return api.sendMessage("โŒ | No onepiece 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 MahMUD.", event.threadID, event.messageID); } } };