mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:26:21 +02:00
Switch math back to mathjs
This commit is contained in:
@@ -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.');
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user