← back to browse
goat command

shell

No description

0
views
0
likes
0
installs

Aliases: sh

raw source
const { exec } = require("child_process");
const fs = require("fs");

module.exports = {
 config: {
 name: "shell",
 version: "1.0.0",
 author: "EryXenX",
 role: 2,
 aliases: ["sh"]
 },
 onStart: async function ({ api, args, event }) {
 let cmd = args.join(" ");
 if (!cmd) return api.sendMessage("Usage: sh <command>", event.threadID, event.messageID);

 exec(cmd, {maxBuffer: 1024 * 1024 * 100}, (err, stdout, stderr) => {
 if (err) return api.sendMessage(`❌ Error: ${err.message}`, event.threadID, event.messageID);
 if (stderr) return api.sendMessage(`⚠️ ${stderr}`, event.threadID, event.messageID);

 let out = stdout || "✅ Command executed successfully";

 if(cmd.startsWith("ls")) {
 let lines = out.split('\n').filter(l => l);
 out = lines.map((item, i) => {
 let icon = "📄";
 try { if(fs.statSync(item).isDirectory()) icon = "📁"; } catch(e) {}
 return `${i + 1}. ${icon} ${item}`;
 }).join('\n');
 } else {
 out = out.split('\n').map((line, i) => `${i + 1}. ${line}`).join('\n');
 }

 let chunks = out.match(/[\s\S]{1,1900}/g) || [out];
 
 chunks.forEach((chunk, i) => {
 setTimeout(() => {
 api.sendMessage(`\`\n${chunk}\n\`\``, event.threadID);
 }, i * 3000); // 3 sec por por
 });
 });
 }
};

View raw file