Math Command

This commit is contained in:
Daniel Odendahl Jr
2017-09-23 13:08:25 +00:00
parent fb4bb67821
commit c0a75d04f1
3 changed files with 35 additions and 15 deletions
+28
View File
@@ -0,0 +1,28 @@
const Command = require('../../structures/Command');
const math = require('mathjs');
module.exports = class MathCommand extends Command {
constructor(client) {
super(client, {
name: 'math',
group: 'num-edit',
memberName: 'math',
description: 'Calculates math expressions.',
args: [
{
key: 'expression',
prompt: 'What expression would you like to calculate?',
type: 'string'
}
]
});
}
run(msg, { expression }) {
try {
return msg.say(math.eval(expression).toString()).catch(() => msg.say('Invalid expression.'));
} catch (err) {
return msg.say('Invalid expression.');
}
}
};