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
-1
View File
@@ -1389,7 +1389,6 @@ here.
* give-flower ([Original "Rune Factory 4" Game](http://www.runefactory4.com/index1.html))
* xiao ([Images, Original "Rune Factory 4" Game](http://www.runefactory4.com/index1.html))
- [mathjs](https://mathjs.org/)
* math (Expression Parser)
* units (Expression Parser)
- [Mattel](https://www.mattel.com/en-us)
* 8-ball ([Original Concept](https://www.mattelgames.com/games/en-us/kids/magic-8-ball))
+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.');
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "123.6.1",
"version": "124.0.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
@@ -45,6 +45,7 @@
"discord.js-commando": "github:discordjs/Commando",
"dotenv": "^8.2.0",
"eslint": "^7.15.0",
"expr-eval": "^2.0.2",
"gifencoder": "^2.0.1",
"gm": "^1.23.1",
"html-entities": "^1.3.1",