f0ckv2/src/inc/trigger/debug.mjs

36 lines
940 B
JavaScript
Raw Normal View History

2019-04-25 18:00:47 +00:00
import { admins } from "../admin";
2018-09-02 10:07:40 +00:00
import vm from "vm";
2019-04-23 15:58:25 +00:00
const maxoutput = 1000;
2018-09-02 10:07:40 +00:00
let context = vm.createContext({
e: null,
bot: null,
admins: null,
});
2019-04-23 15:58:25 +00:00
export default bot => bot._trigger.set("sandbox_debug", new bot.trigger({
call: /^\!debug (.*)/i,
level: 100,
active: true,
f: e => {
const args = e.message.trim().substring(7);
if(args === "true" || args === "false")
return e.self.debug = !e.self.debug;
try {
context.admins = admins;
context.e = e;
context.bot = bot;
let output = vm.runInContext(args, vm.createContext(context));
if (typeof output !== undefined && output) {
output = JSON.stringify(output);
2019-04-25 18:00:47 +00:00
return r.reply(output.length > maxoutput ? `holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)` : output);
2018-09-02 10:07:40 +00:00
}
2019-04-25 18:00:47 +00:00
else
e.reply("false lol");
2018-09-02 10:07:40 +00:00
}
2019-04-23 15:58:25 +00:00
catch (err) {
e.reply(err.message);
}
}
2018-09-02 10:07:40 +00:00
}));