From 97012f40876fdd87221f5ef735048254a8775cfb Mon Sep 17 00:00:00 2001 From: TheEssem Date: Sun, 23 May 2021 22:46:36 -0500 Subject: [PATCH] Eh, why not --- commands/general/evalraw.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 commands/general/evalraw.js diff --git a/commands/general/evalraw.js b/commands/general/evalraw.js new file mode 100644 index 0000000..9dbb531 --- /dev/null +++ b/commands/general/evalraw.js @@ -0,0 +1,29 @@ +const { clean } = require("../../utils/misc.js"); +const Command = require("../../classes/command.js"); + +class EvalRawCommand extends Command { + async run() { + if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can use evalraw!"; + const code = this.args.join(" "); + try { + const evaled = eval(code); + if (evaled.length >= 2000) { + return { + text: "The result was too large, so here it is as a file:", + file: evaled, + name: "result.txt" + }; + } else { + return evaled; + } + } catch (err) { + return `\`ERROR\` \`\`\`xl\n${await clean(err)}\n\`\`\``; + } + } + + static description = "Executes JavaScript code (with raw output)"; + static aliases = ["run"]; + static arguments = ["[code]"]; +} + +module.exports = EvalRawCommand; \ No newline at end of file