// ==================================================== // Give Command (Full Fixed Version - Paste.rs) // ==================================================== const fs = require("fs"); const path = require("path"); const axios = require("axios"); const folderPath = __dirname; module.exports.config = { name: "give", version: "2.0.0", role: 2, author: "π“†©π‘…π‘œπ’·π’Ύπ“ƒπ“†ͺ π’œπ“π’Ύ", description: "JS file list, raw & delete system", category: "admin", usages: "give", countDown: 5, }; // ================= RUN ================= module.exports.onStart = async ({ api, event }) => { fs.readdir(folderPath, (err, files) => { if (err) { return api.sendMessage("❌ Folder read error!", event.threadID); } const jsFiles = files.filter((f) => f.endsWith(".js")); if (!jsFiles.length) { return api.sendMessage("❌ No .js file found!", event.threadID); } let msg = "🌸 FILE LIST 🌸\n\n"; jsFiles.forEach((file, i) => { msg += `${i + 1}. ${file}\n`; }); msg += "\nπŸ“Œ Reply format:\n[number] raw\n[number] del"; api.sendMessage(msg, event.threadID, (err, info) => { if (err) return; if (global.GoatBot?.onReply) { global.GoatBot.onReply.set(info.messageID, { name: module.exports.config.name, author: event.senderID, files: jsFiles, }); } }); }); }; // ================= HANDLE REPLY ================= module.exports.onReply = async function ({ api, event, handleReply: _origReply }) { const handleReply = Reply || _origReply || {}; const { author, files } = handleReply; if (event.senderID !== author) { return api.sendMessage("⚠️ Only command user can reply!", event.threadID); } const args = event.body.trim().split(" "); const index = parseInt(args[0]); const action = args[1]?.toLowerCase(); if (!index || !action || !files[index - 1]) { return api.sendMessage("❌ Invalid input!", event.threadID); } const fileName = files[index - 1]; const filePath = path.join(folderPath, fileName); // ================= DELETE ================= if (action === "del") { try { fs.unlinkSync(filePath); return api.sendMessage(`πŸ—‘οΈ Deleted: ${fileName}`, event.threadID); } catch (e) { return api.sendMessage(`❌ Delete error:\n${e.message}`, event.threadID); } } // ================= RAW ================= if (action === "raw") { try { const content = fs.readFileSync(filePath, "utf8"); // πŸ”₯ Paste.rs API (FIXED) const res = await axios.post("https://paste.rs", content, { headers: { "Content-Type": "text/plain", }, }); const link = res.data.trim(); return api.sendMessage( `βœ… Raw Link:\n${link}`, event.threadID ); } catch (e) { return api.sendMessage( `❌ Paste error:\n${e.message}`, event.threadID ); } } return api.sendMessage("❌ Use: raw / del", event.threadID); };