Initial commit
This commit is contained in:
37
src/inc/trigger/debug.mjs
Normal file
37
src/inc/trigger/debug.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
import { admins, getLevel } from "../admin";
|
||||
|
||||
import vm from "vm";
|
||||
|
||||
const maxoutput = 750;
|
||||
let context = vm.createContext({
|
||||
e: null,
|
||||
bot: null,
|
||||
admins: null,
|
||||
});
|
||||
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);
|
||||
try {
|
||||
context.admins = admins;
|
||||
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
|
||||
return e.reply(output);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
e.reply(err.message);
|
||||
}
|
||||
}
|
||||
}));
|
||||
};
|
Reference in New Issue
Block a user