Math command is back again

This commit is contained in:
Daniel Odendahl Jr
2017-12-05 17:28:59 +00:00
parent 2558256c0d
commit 8cfdf56c93
2 changed files with 32 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
const { Command } = require('discord.js-commando');
const math = require('mathjs');
module.exports = class MathCommand extends Command {
constructor(client) {
super(client, {
name: 'math',
aliases: ['mathematics', 'solve'],
group: 'number-edit',
memberName: 'math',
description: 'Evaluates a math expression.',
args: [
{
key: 'expression',
prompt: 'What expression do you want to evaluate?',
type: 'string'
}
]
});
}
run(msg, { expression }) {
try {
const evaluated = math.eval(expression).toString();
return msg.say(evaluated).catch(() => msg.say('Invalid expression.'));
} catch (err) {
return msg.say('Invalid expression.');
}
}
};
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "56.0.1",
"version": "56.1.0",
"description": "Your personal server companion.",
"main": "XiaoBot.js",
"scripts": {
@@ -37,6 +37,7 @@
"discord.js": "github:hydrabolt/discord.js",
"discord.js-commando": "github:dragonfire535/discord.js-commando#default-functions",
"erlpack": "github:discordapp/erlpack",
"mathjs": "^3.17.0",
"node-opus": "^0.2.7",
"snekfetch": "^3.6.0",
"uws": "^8.14.1",