{"size": 486, "ext": "js", "max_stars_repo_path": "commands/default/math.js", "max_stars_repo_name": "drlau/magejs", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "commands/default/math.js", "max_issues_repo_name": "drlau/magejs", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commands/default/math.js", "max_forks_repo_name": "drlau/magejs", "max_forks_repo_forks_event_min_datetime": "2019-06-03T14:54:42.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-03T14:54:42.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 22.0909090909, "max_line_length": 65, "alphanum_fraction": 0.6502057613}
const math = require("mathjs");

exports.cmd = new Mage.Command("math", async message => {
	let result;
	try {
		result = math.eval(message.args.join(" "));
	} catch(error) {
		result = undefined;
	}

	if(!result) message.channel.createMessage("Invalid Expression");
	else message.channel.createMessage("**Result:** " + result);
}, {
	type: "default",
	aliases: ["calc", "calculate"],
	description: "Calculate a math expression",
	args: [{
		type: "text",
		label: "expression"
	}]
});
