Friday, September 20, 2024 1:35:24 AM
> settings

Customize


Authenticate

> eval.js
const ESMCommand = require("../esm_command");
const jsUtil = require('util');
module.exports = class ESMCommand_Eval extends ESMCommand {
    constructor(bot) {
        super(bot);
        this.permissions = {
            dev_only: true
        };

        this.commandParams = {
            code: {
                regex: /[\s\S]+/,
                preserve_case: true
            }
        };
    }

    async fromDiscord() {
        let response = "Failed to evaluate code";
        let code = this.params.code.trim();
        let output = `Input:\n\`\`\`js\n${code}\`\`\``;

        try {
            response = eval(code);

            if (this.util.isObject(response)) {
                response = jsUtil.inspect(response);
            }

            if (this.util.isNull(response)) throw "<null>";
        } catch (err) {
            response = err;
        }

        if (response.length > 1650) {
            output += `\nOutput:\n\`\`\`js\n${response.substring(0, 1650)}\n\`\`\``;
            await this.ESMBot.send(this.message.channel, output);
            let newResponse = response.substring(1650);
            for (let i = 0; i < (newResponse.length / 1650); i++) {
                let messageToSend = newResponse.substring(i * 1650, (i + 1) * 1650);
                await this.ESMBot.send(this.message.channel, `\`\`\`js\n${messageToSend}\`\`\``);
            }
        } else {
            output += `\nOutput:\n\`\`\`js\n${response}\n\`\`\``;
            this.ESMBot.send(this.message.channel, output);
        }
    }
}
All opinions represented herein are my own
- © 2024 itsthedevman
- build 340fbb8