args and more

This commit is contained in:
Daniel Odendahl Jr
2017-03-25 04:16:27 +00:00
parent 8dd6ec1f9b
commit e2a4a92990
82 changed files with 1089 additions and 1021 deletions
+9 -7
View File
@@ -14,22 +14,24 @@ module.exports = class MathCommand extends commando.Command {
group: 'numedit',
memberName: 'math',
description: 'Does Math (;math 2 + 2)',
examples: [';math 2 + 2']
examples: [';math 2 + 2'],
args: [{
key: 'expression',
prompt: 'What do you want to answer?',
type: 'string'
}]
});
}
run(message) {
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let expression = message.content.split(" ").slice(1).join(" ");
let expression = args.expression;
try {
let solved = math.eval(expression);
return message.channel.send(solved).catch(err => {
console.log(err);
message.channel.send(":x: Error! Invalid statement!");
});
return message.channel.send(solved).catch(err => message.channel.send(":x: Error! Invalid statement!"));
}
catch (err) {
return message.channel.send(":x: Error! Invalid statement!");