// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); module.exports = { config: { name: "push", version: "3.0.0", author: "šŒššš‘š®š…", role: 2, category: "owner" }, onStart: async function ({ message, args }) { const TOKEN = (process.env.GITHUB_TOKEN || process.env.GH_TOKEN || global.GoatBot?.config?.githubToken || "").toString().trim(); const USER = "primemaruf7"; const REPO = "Prime"; const BRANCH = "main"; if (!TOKEN) return message.reply("āŒ GITHUB_TOKEN env e nai"); if (!args[0]) return message.reply("use: push "); const headers = { Authorization: `Bearer ${TOKEN}`, Accept: "application/vnd.github.v3+json", "User-Agent": "Prime-Bot" }; const dir = path.join(process.cwd(), "scripts/cmds"); const files = [...new Set(args.map(a => a.replace(/\.js$/i, "").trim()))]; if (files.length === 1) { const name = files[0]; const filePath = path.join(dir, `${name}.js`); if (!await fs.pathExists(filePath)) return message.reply(`āŒ File Not Found: ${name}.js`); const content = await fs.readFile(filePath, "utf8"); const url = `https://api.github.com/repos/${USER}/${REPO}/contents/scripts/cmds/${name}.js`; let sha; try { const res = await axios.get(url, { headers, params: { ref: BRANCH } }); sha = res.data.sha; } catch {} try { await axios.put(url, { message: `${sha? "Update" : "Add"} ${name}`, content: Buffer.from(content).toString("base64"), branch: BRANCH, ...(sha && { sha }) }, { headers }); return message.reply(sha? `šŸ”„ Rewrite Successful: ${name}.js` : `āœ… Upload Successful: ${name}.js`); } catch (e) { return message.reply(`āŒ GitHub API Error: ${e.response?.data?.message || e.message}`); } } let uploaded = 0, rewritten = 0, failed = 0; let logs = []; for (const name of files) { try { const filePath = path.join(dir, `${name}.js`); if (!await fs.pathExists(filePath)) { failed++; logs.push(`āŒ ${name} - not found`); continue; } const content = await fs.readFile(filePath, "utf8"); const url = `https://api.github.com/repos/${USER}/${REPO}/contents/scripts/cmds/${name}.js`; let sha; try { const res = await axios.get(url, { headers, params: { ref: BRANCH } }); sha = res.data.sha; } catch {} await axios.put(url, { message: `${sha? "Update" : "Add"} ${name}`, content: Buffer.from(content).toString("base64"), branch: BRANCH, ...(sha && { sha }) }, { headers }); if (sha) { rewritten++; logs.push(`šŸ”„ ${name} - rewritten`); } else { uploaded++; logs.push(`āœ… ${name} - uploaded`); } } catch (err) { failed++; logs.push(`āŒ ${name} - ${err.response?.data?.message || "failed"}`); } } return message.reply(`šŸ“¦ Push Complete\n\nāœ… Uploaded: ${uploaded}\nšŸ”„ Rewritten: ${rewritten}\nāŒ Failed: ${failed}\n\n${logs.join("\n")}`); } };