goat
command
give
JS file list, raw & delete system
0
views
0
likes
0
installs
raw source
// ====================================================
// 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);
};