Destructuring Args

This commit is contained in:
Daniel Odendahl Jr
2017-04-19 12:21:38 +00:00
parent 4fc536531d
commit e105b6aa5d
72 changed files with 228 additions and 167 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ module.exports = class MathCommand extends Command {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const expression = args.expression;
const { expression } = args;
try {
const solved = math.eval(expression);
return message.say(solved).catch(() => message.say(':x: Error! Invalid statement!'));
+3 -4
View File
@@ -15,8 +15,7 @@ module.exports = class MotivateCommand extends Command {
args: [{
key: 'thing',
prompt: 'What do you want to motivate?',
type: 'string',
default: ''
type: 'string'
}]
});
}
@@ -25,7 +24,7 @@ module.exports = class MotivateCommand extends Command {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const motivated = args.thing || message.author;
return message.say(`${motivated}, https://www.youtube.com/watch?v=ZXsQAXx_ao0`);
const { thing } = args;
return message.say(`${thing}, https://www.youtube.com/watch?v=ZXsQAXx_ao0`);
}
};
+1 -2
View File
@@ -36,8 +36,7 @@ module.exports = class StrawpollCommand extends Command {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const title = args.title;
const choices = args.choices;
const { title, choices } = args;
if (choices.length < 2) return message.say(':x: Error! You provided less than two choices!');
if (choices.length > 31) return message.say(':x: Error! You provided more than thirty choices!');
try {