async debug

This commit is contained in:
Flummi 2021-05-16 13:23:19 +02:00
parent 964391f384
commit 3bc0a74932

View File

@ -1,5 +1,6 @@
import { getLevel } from "../admin.mjs"; import { getLevel } from "../admin.mjs";
import fetch from "flumm-fetch-cookies"; import fetch from "flumm-fetch-cookies";
import sql from "../sql.mjs";
import vm from "vm"; import vm from "vm";
@ -8,7 +9,11 @@ let context = vm.createContext({
e: null, e: null,
bot: null, bot: null,
admins: null, admins: null,
fetch: fetch sql: sql,
fetch: fetch,
a: null,
resolve: null
}); });
export default async bot => { export default async bot => {
@ -30,29 +35,29 @@ export default async bot => {
} }
}, { }, {
name: "sandbox_debug", name: "sandbox_debug",
call: /^\!debug (.*)/i, call: /^\!f0ck debug (.*)/i,
active: true, active: true,
level: 100, level: 100,
f: e => { f: async e => {
const args = e.message.trim().substring(7); const args = e.message.trim().substring(12);
try {
context.e = e; context.e = e;
context.bot = bot; context.bot = bot;
context.level = getLevel; context.level = getLevel;
let output = vm.runInContext(args, vm.createContext(context)); context.a = null;
if (typeof output !== undefined && output) {
output = JSON.stringify(output); await new Promise(resolve => {
if (output.length > maxoutput) context.resolve = resolve;
return e.reply(`holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`); const code = "Promise.resolve().then(async result => { a = await (async () => "+args+")(); resolve(); }).catch(err => { a = err; resolve(); })";
const script = new vm.Script(code);
script.runInContext(context);
});
let output = JSON.stringify(context.a);
if(output.length > maxoutput)
return e.reply(`fuggg, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`);
else else
e.reply(output); return e.reply(output);
}
else
e.reply("false lol");
}
catch (err) {
e.reply(err.message);
}
} }
}]; }];
}; };