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)) * 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)) * xiao ([Images, Original "Rune Factory 4" Game](http://www.runefactory4.com/index1.html))
- [mathjs](https://mathjs.org/) - [mathjs](https://mathjs.org/)
* math (Expression Parser)
* units (Expression Parser) * units (Expression Parser)
- [Mattel](https://www.mattel.com/en-us) - [Mattel](https://www.mattel.com/en-us)
* 8-ball ([Original Concept](https://www.mattelgames.com/games/en-us/kids/magic-8-ball)) * 8-ball ([Original Concept](https://www.mattelgames.com/games/en-us/kids/magic-8-ball))
+2 -9
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const math = require('mathjs'); const { Parser } = require('expr-eval');
module.exports = class MathCommand extends Command { module.exports = class MathCommand extends Command {
constructor(client) { constructor(client) {
@@ -9,13 +9,6 @@ module.exports = class MathCommand extends Command {
group: 'edit-number', group: 'edit-number',
memberName: 'math', memberName: 'math',
description: 'Evaluates a math expression.', description: 'Evaluates a math expression.',
credit: [
{
name: 'mathjs',
url: 'https://mathjs.org/',
reason: 'Expression Parser'
}
],
args: [ args: [
{ {
key: 'expression', key: 'expression',
@@ -28,7 +21,7 @@ module.exports = class MathCommand extends Command {
run(msg, { expression }) { run(msg, { expression }) {
try { try {
const evaluated = math.evaluate(expression).toString(); const evaluated = Parser.evaluate(expression).toString();
return msg.reply(evaluated).catch(() => msg.reply('Invalid expression.')); return msg.reply(evaluated).catch(() => msg.reply('Invalid expression.'));
} catch { } catch {
return msg.reply('Invalid expression.'); return msg.reply('Invalid expression.');
+2 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "123.6.1", "version": "124.0.0",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {
@@ -45,6 +45,7 @@
"discord.js-commando": "github:discordjs/Commando", "discord.js-commando": "github:discordjs/Commando",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"eslint": "^7.15.0", "eslint": "^7.15.0",
"expr-eval": "^2.0.2",
"gifencoder": "^2.0.1", "gifencoder": "^2.0.1",
"gm": "^1.23.1", "gm": "^1.23.1",
"html-entities": "^1.3.1", "html-entities": "^1.3.1",