possumbot/commands/eval.js
2024-08-27 19:52:32 +00:00

25 lines
624 B
JavaScript

import { xxh64 } from "@node-rs/xxhash";
import { encode } from "html-entities";
import { JSDOM } from "jsdom";
import util from "util";
import fs from "fs";
function execute(client, event, args) {
var c = "";
try {
var result = eval(args);
c = util.format(result).replaceAll(process.env.ACCESS_TOKEN, "*".repeat(process.env.ACCESS_TOKEN.length));
} catch(err) {
c = util.format(err);
}
client.reply(event, c, `<pre><code>${encode(c)}</code></pre>`);
}
export default {
command: "eval",
name: "eval",
usage: "<code>",
owner: true,
desc: "run JS code and reply with the result",
execute
}