paste my eval/exec code

This commit is contained in:
Lamp 2022-01-03 22:26:27 -08:00
parent da4e033760
commit fb0c39b5c8
3 changed files with 38 additions and 1 deletions

View File

@ -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

37
eval-exec.js Normal file
View File

@ -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);
}
});

View File

@ -33,6 +33,7 @@ dClient.login(config.DISCORD_TOKEN);
dClient.once('ready', () => {
console.log('Discord Client Ready');
require('./eval-exec');
require('./mppbridger');
require('./misc');
require('./ddpbridge');