eval: add depth option
This commit is contained in:
parent
f54ec82c99
commit
43461f6627
1 changed files with 5 additions and 3 deletions
|
@ -82,19 +82,21 @@ const _eval = new Command("eval");
|
||||||
_eval.elevatedOnly = true;
|
_eval.elevatedOnly = true;
|
||||||
_eval.category = CATEGORY;
|
_eval.category = CATEGORY;
|
||||||
_eval.helpText = "Evalueates Javascript";
|
_eval.helpText = "Evalueates Javascript";
|
||||||
_eval.callback = async function (msg, line) {
|
_eval.callback = async function (msg, line, args, {depth = 0}) {
|
||||||
let errored = false;
|
let errored = false;
|
||||||
let out;
|
let out;
|
||||||
|
|
||||||
|
const code = args.join(" ");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
out = eval(line);
|
out = eval(code);
|
||||||
if (out && out instanceof Promise) out = await out;
|
if (out && out instanceof Promise) out = await out;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
out = err.toString();
|
out = err.toString();
|
||||||
errored = true;
|
errored = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
out = errored ? out : inspect(out, {depth: 0});
|
out = errored ? out : inspect(out, {depth});
|
||||||
|
|
||||||
const token = hf.config.token;
|
const token = hf.config.token;
|
||||||
out = out.replace(new RegExp(token.replace(/\./g, "\\."), "g"), "lol no key 4 u");
|
out = out.replace(new RegExp(token.replace(/\./g, "\\."), "g"), "lol no key 4 u");
|
||||||
|
|
Loading…
Reference in a new issue