mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-09 09:12:07 +02:00
Switch math command to expr-eval
This commit is contained in:
@@ -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.');
|
||||
|
||||
Reference in New Issue
Block a user