Switch math back to mathjs

This commit is contained in:
Dragon Fire
2021-05-03 17:08:16 -04:00
parent c5caeb75aa
commit 995ab23c81
2 changed files with 12 additions and 4 deletions
+12 -3
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command');
const { Parser } = require('expr-eval');
const core = require('mathjs/number');
const math = core.create(core.all);
module.exports = class MathCommand extends Command {
constructor(client) {
@@ -15,14 +16,22 @@ module.exports = class MathCommand extends Command {
prompt: 'What expression do you want to evaluate?',
type: 'string'
}
],
credit: [
{
name: 'mathjs',
url: 'https://mathjs.org/',
reason: 'Expression Parser'
}
]
});
}
run(msg, { expression }) {
try {
const evaluated = Parser.evaluate(expression).toString();
return msg.reply(evaluated).catch(() => msg.reply('Invalid expression.'));
const evaluated = math.evaluate(expression);
if (typeof result === 'function') return msg.reply('Invalid expression.');
return msg.reply(evaluated.toString());
} catch {
return msg.reply('Invalid expression.');
}
-1
View File
@@ -52,7 +52,6 @@
"dotenv": "^8.2.0",
"emoji-regex": "^9.2.2",
"eslint": "^7.25.0",
"expr-eval": "^2.0.2",
"fen-validator": "^1.4.1",
"font-finder": "^1.1.0",
"gifencoder": "^2.0.1",