eval: add depth option

This commit is contained in:
Cynthia Foxwell 2024-08-30 21:16:51 -06:00
parent f54ec82c99
commit 43461f6627

View file

@ -82,19 +82,21 @@ const _eval = new Command("eval");
_eval.elevatedOnly = true;
_eval.category = CATEGORY;
_eval.helpText = "Evalueates Javascript";
_eval.callback = async function (msg, line) {
_eval.callback = async function (msg, line, args, {depth = 0}) {
let errored = false;
let out;
const code = args.join(" ");
try {
out = eval(line);
out = eval(code);
if (out && out instanceof Promise) out = await out;
} catch (err) {
out = err.toString();
errored = true;
}
out = errored ? out : inspect(out, {depth: 0});
out = errored ? out : inspect(out, {depth});
const token = hf.config.token;
out = out.replace(new RegExp(token.replace(/\./g, "\\."), "g"), "lol no key 4 u");