Switch math command to expr-eval

This commit is contained in:
Dragon Fire
2020-12-15 17:36:03 -05:00
parent a099cd2d4d
commit c955b56eae
3 changed files with 5 additions and 12 deletions
+3 -10
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command');
const math = require('mathjs');
const { Parser } = require('expr-eval');
module.exports = class MathCommand extends Command {
constructor(client) {
@@ -9,13 +9,6 @@ module.exports = class MathCommand extends Command {
group: 'edit-number',
memberName: 'math',
description: 'Evaluates a math expression.',
credit: [
{
name: 'mathjs',
url: 'https://mathjs.org/',
reason: 'Expression Parser'
}
],
args: [
{
key: 'expression',
@@ -27,8 +20,8 @@ module.exports = class MathCommand extends Command {
}
run(msg, { expression }) {
try {
const evaluated = math.evaluate(expression).toString();
try {
const evaluated = Parser.evaluate(expression).toString();
return msg.reply(evaluated).catch(() => msg.reply('Invalid expression.'));
} catch {
return msg.reply('Invalid expression.');