possumbot/commands/eval.js

26 lines
624 B
JavaScript
Raw Normal View History

2024-08-27 21:52:32 +02:00
import { xxh64 } from "@node-rs/xxhash";
2024-08-21 17:00:40 +02:00
import { encode } from "html-entities";
2024-08-27 21:52:32 +02:00
import { JSDOM } from "jsdom";
2024-08-21 17:00:40 +02:00
import util from "util";
2024-08-27 21:52:32 +02:00
import fs from "fs";
2024-08-21 17:00:40 +02:00
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,
2024-08-27 21:52:32 +02:00
desc: "run JS code and reply with the result",
2024-08-21 17:00:40 +02:00
execute
}