Skip to content

Instantly share code, notes, and snippets.

@BlueSlimee
Created September 10, 2018 23:05
Show Gist options
  • Save BlueSlimee/5228dd5fd03712a6e8827bf918fd26ce to your computer and use it in GitHub Desktop.
Save BlueSlimee/5228dd5fd03712a6e8827bf918fd26ce to your computer and use it in GitHub Desktop.
Comando de exec da kanarinha
const { Command } = require('discord.js-commando');
class ExecCommand extends Command {
constructor (client) {
super (client, {
name: "exec",
aliases: ["bash"],
group: "commands",
memberName: "exec",
description: "Run something on terminal",
guildOnly: false,
args: [{
key: 'text',
label: 'text',
prompt: "NO COMMAND! Enter the command to run",
type: "string"
}]
});
}
async run (msg, { text }) {
if (msg.author.id != "201710904612618240") return;
const { spawn } = require('child_process');
var a = [];
var o = await msg.channel.send("Just a sec...");
var cmdarr = text.split(" ");
var fcmd = cmdarr.shift();
const ls = spawn(fcmd, cmdarr);
ls.stdout.on('data', (data) => {
if (a.length > 15) a = [];
a.push(data);
setTimeout(() => { o.edit("```"+ a.join('\n') +"```") }, 500);
});
ls.stderr.on('data', (data) => {
if (a.length > 15) a =[];
a.push(data);
setTimeout(() => { o.edit("```"+ a.join('\n') +"```"); }, 500)
});
ls.on('close', (code) => {
if (a.length > 15) a =[];
a.push("OK; Finished with code "+ code);
setTimeout(() => { o.edit("```"+ a.join('\n') +"```"); }, 500)
});
}
}
module.exports = ExecCommand;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment