paste my eval/exec code
This commit is contained in:
parent
da4e033760
commit
fb0c39b5c8
|
@ -12,7 +12,6 @@ module.exports = {
|
|||
},
|
||||
|
||||
"opID": "707359017252683896",
|
||||
"opIDs": ["707359017252683896", "330499035419115522"], //TODO i dont need multiple ops anymore
|
||||
"guildID": testmode ? "467473467634089985" : "321819041348190249",
|
||||
|
||||
"channels": { // includes voice channels & category channels
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
client.on("messageCreate", async function (message) {
|
||||
if (message.author.id != config.opID) return;
|
||||
if (message.content.startsWith("!>")) {
|
||||
with (message) {
|
||||
try {
|
||||
var x = await eval(message.content.substr(2).trim());
|
||||
} catch(e) {
|
||||
var x = e.message;
|
||||
}
|
||||
}
|
||||
if (typeof x == "undefined") return void await message.react(config.eval_undefined_emoji);
|
||||
let t = typeof x == 'string' ? 'txt' : 'js';
|
||||
if (typeof x != 'string' && typeof x != "function") x = require('util').inspect(x, {depth: 1});
|
||||
let cb = `\`\`\`${t}\n${x}\`\`\``;
|
||||
if (cb.length <= 2000)
|
||||
message.channel.send(cb);
|
||||
else
|
||||
message.channel.send({files:[{
|
||||
attachment: Buffer.from(x),
|
||||
name: `output.${t}`
|
||||
}]});
|
||||
}
|
||||
else if (message.content.startsWith("!$")) {
|
||||
let cp = require("child_process").spawn("bash", ["-c", message.content.substr(2).trim()]);
|
||||
function ondat(a) {
|
||||
try {
|
||||
var split = Discord.Util.splitMessage(a.toString(), {split:{char:'\n',length:2000}});
|
||||
} catch(x) {
|
||||
var split = Discord.Util.splitMessage(a.toString(), {split:{char:'',length:2000}});
|
||||
}
|
||||
split.forEach(message.channel.send.bind(message.channel));
|
||||
}
|
||||
cp.stdout.on("data", ondat);
|
||||
cp.stderr.on("data", ondat);
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue