mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 08:22:37 +02:00
Fix
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const core = require('mathjs/number');
|
const core = require('mathjs/number');
|
||||||
const math = core.create(core.all);
|
const math = core.create(core.all);
|
||||||
|
const limitedEvaluate = math.evaluate;
|
||||||
math.import({
|
math.import({
|
||||||
import: () => { throw new Error('Function import is disabled'); },
|
import: () => { throw new Error('Function import is disabled'); },
|
||||||
createUnit: () => { throw new Error('Function createUnit is disabled'); },
|
createUnit: () => { throw new Error('Function createUnit is disabled'); },
|
||||||
|
evaluate: () => { throw new Error('Function evaluate is disabled'); },
|
||||||
|
parse: () => { throw new Error('Function parse is disabled'); },
|
||||||
simplify: () => { throw new Error('Function simplify is disabled'); },
|
simplify: () => { throw new Error('Function simplify is disabled'); },
|
||||||
derivative: () => { throw new Error('Function derivative is disabled'); }
|
derivative: () => { throw new Error('Function derivative is disabled'); }
|
||||||
}, { override: true });
|
}, { override: true });
|
||||||
@@ -35,7 +38,7 @@ module.exports = class MathCommand extends Command {
|
|||||||
|
|
||||||
run(msg, { expression }) {
|
run(msg, { expression }) {
|
||||||
try {
|
try {
|
||||||
const evaluated = math.evaluate(expression);
|
const evaluated = limitedEvaluate(expression);
|
||||||
if (typeof evaluated === 'function') return msg.reply('Invalid expression.');
|
if (typeof evaluated === 'function') return msg.reply('Invalid expression.');
|
||||||
return msg.reply(evaluated.toString());
|
return msg.reply(evaluated.toString());
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user