Files
xiao/commands/random/math.js
T
Daniel Odendahl Jr 657b7b727d More Clean-Ups
2017-04-25 14:04:07 +00:00

30 lines
839 B
JavaScript

const { Command } = require('discord.js-commando');
const math = require('mathjs');
module.exports = class MathCommand extends Command {
constructor(client) {
super(client, {
name: 'math',
group: 'random',
memberName: 'math',
description: 'Does math.',
args: [{
key: 'expression',
prompt: 'What do you want to answer?',
type: 'string'
}]
});
}
run(message, args) {
const { expression } = args;
try {
const solved = math.eval(expression);
return message.say(solved)
.catch(() => message.say(':x: Error! Invalid statement!'));
} catch (err) {
return message.say(':x: Error! Invalid statement!');
}
}
};