async debug
This commit is contained in:
parent
964391f384
commit
3bc0a74932
@ -1,5 +1,6 @@
|
||||
import { getLevel } from "../admin.mjs";
|
||||
import fetch from "flumm-fetch-cookies";
|
||||
import sql from "../sql.mjs";
|
||||
|
||||
import vm from "vm";
|
||||
|
||||
@ -8,7 +9,11 @@ let context = vm.createContext({
|
||||
e: null,
|
||||
bot: null,
|
||||
admins: null,
|
||||
fetch: fetch
|
||||
sql: sql,
|
||||
fetch: fetch,
|
||||
|
||||
a: null,
|
||||
resolve: null
|
||||
});
|
||||
|
||||
export default async bot => {
|
||||
@ -30,29 +35,29 @@ export default async bot => {
|
||||
}
|
||||
}, {
|
||||
name: "sandbox_debug",
|
||||
call: /^\!debug (.*)/i,
|
||||
call: /^\!f0ck debug (.*)/i,
|
||||
active: true,
|
||||
level: 100,
|
||||
f: e => {
|
||||
const args = e.message.trim().substring(7);
|
||||
try {
|
||||
context.e = e;
|
||||
context.bot = bot;
|
||||
context.level = getLevel;
|
||||
let output = vm.runInContext(args, vm.createContext(context));
|
||||
if (typeof output !== undefined && output) {
|
||||
output = JSON.stringify(output);
|
||||
if (output.length > maxoutput)
|
||||
return e.reply(`holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`);
|
||||
else
|
||||
e.reply(output);
|
||||
}
|
||||
else
|
||||
e.reply("false lol");
|
||||
}
|
||||
catch (err) {
|
||||
e.reply(err.message);
|
||||
}
|
||||
f: async e => {
|
||||
const args = e.message.trim().substring(12);
|
||||
|
||||
context.e = e;
|
||||
context.bot = bot;
|
||||
context.level = getLevel;
|
||||
context.a = null;
|
||||
|
||||
await new Promise(resolve => {
|
||||
context.resolve = resolve;
|
||||
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
|
||||
return e.reply(output);
|
||||
}
|
||||
}];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user