f0ckv2/src/inc/trigger/debug.mjs

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-04-02 02:35:28 +00:00
import { getLevel } from "../admin.mjs";
import fetch from "flumm-fetch-cookies";
2018-09-02 10:07:40 +00:00
import vm from "vm";
2020-04-02 02:35:28 +00:00
let maxoutput = 750;
2018-09-02 10:07:40 +00:00
let context = vm.createContext({
e: null,
bot: null,
admins: null,
2020-04-02 02:35:28 +00:00
fetch: fetch
2018-09-02 10:07:40 +00:00
});
2019-04-25 18:00:47 +00:00
2020-04-02 02:35:28 +00:00
export default async bot => {
return [{
name: "level",
call: /^!level (.*)/i,
active: true,
f: e => {
const user = e.message.trim().substring(7);
e.reply( JSON.stringify( getLevel( e.self.user.get(user) || {} ) ) );
2018-09-02 10:07:40 +00:00
}
2020-04-02 02:35:28 +00:00
}, {
name: "sandbox_debug",
call: /^\!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);
}
2019-04-23 15:58:25 +00:00
}
2020-04-02 02:35:28 +00:00
}];
};