{"size": 1570, "ext": "js", "max_stars_repo_path": "src/commands/eval.js", "max_stars_repo_name": "austinhuang0131/Assyst", "max_stars_repo_stars_event_min_datetime": "2020-01-12T21:41:45.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-12T21:41:45.000Z", "max_issues_repo_path": "src/commands/eval.js", "max_issues_repo_name": "austinhuang0131/Assyst", "max_issues_repo_issues_event_min_datetime": "2019-10-21T18:08:39.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T07:59:21.000Z", "max_forks_repo_path": "src/commands/eval.js", "max_forks_repo_name": "austinhuang0131/Assyst", "max_forks_repo_forks_event_min_datetime": "2019-08-31T12:35:42.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-31T12:35:42.000Z"}
{"max_stars_count": 1, "max_issues_count": 3, "max_forks_count": 1, "avg_line_length": 31.4, "max_line_length": 87, "alphanum_fraction": 0.5662420382}
const { Command } = require('../../lib/Command.js');
// eslint-disable-next-line consistent-return
const command = new Command( ['eval', 'e'], 2, 1000, async function ( { msg, args } ) {
    let evaled;
    const flags = this.utils.resolveFlags(args, [] );
    if (flags.map(i => i.flagName).includes('files.gg') ) {
        args = this.utils.removeFlags(args);
    }
    try {
        evaled = await eval(args.join(' ') ); // eslint-disable-line no-eval
    } catch (err) {
        return this.sendMsg(msg.channel, err, 'error');
    }

    if (typeof evaled === 'object') {
        evaled = require('util').inspect(evaled, { depth: 0, showHidden: true } );
    } else {
        evaled = String(evaled);
    }

    evaled = evaled.split(this.bot.token).join(' ');

    const fullLen = evaled.length;

    if (fullLen === 0) { // eslint-disable-line no-magic-numbers
        return null;
    }

    if (flags.map(i => i.flagName).includes('files.gg') ) {
        const file = await this.utils.uploadToFilesGG(evaled, 'evaloutput.js');
        this.sendMsg(msg.channel, file);
    } else {
        if (fullLen > 2000) { // eslint-disable-line no-magic-numbers
            const file = await this.utils.uploadToFilesGG(evaled, 'evaloutput.js');
            this.sendMsg(msg.channel, file);
        }
        return this.sendMsg(msg.channel, `\`\`\`js\n${evaled}\`\`\``);
    }
} );
module.exports = {
    command,
    info: {
        description: 'Evaluate code',
        author: 'Jacherr',
        usage: 'e [code]',
        examples: ['e 1+1', 'e this.bot'],
    },
};

