Cleaner Looking args

This commit is contained in:
Daniel Odendahl Jr
2017-05-02 17:54:07 +00:00
parent 57ee7fa82b
commit 3bb21c2df0
83 changed files with 787 additions and 616 deletions
+13 -11
View File
@@ -11,17 +11,19 @@ module.exports = class EasterEggCommand extends Command {
group: 'random',
memberName: 'easteregg',
description: 'Can you discover all the easter eggs?',
args: [{
key: 'tag',
prompt: 'What easter egg do you want to view?',
type: 'string',
validate: tag => {
if (eastereggs[tag.toLowerCase()])
return true;
return 'Nope, that\'s not a valid easter egg. Try again!';
},
parse: tag => tag.toLowerCase()
}]
args: [
{
key: 'tag',
prompt: 'What easter egg do you want to view?',
type: 'string',
validate: tag => {
if (eastereggs[tag.toLowerCase()])
return true;
return 'Nope, that\'s not a valid easter egg. Try again!';
},
parse: tag => tag.toLowerCase()
}
]
});
}
+7 -5
View File
@@ -8,11 +8,13 @@ module.exports = class MathCommand extends Command {
group: 'random',
memberName: 'math',
description: 'Does math.',
args: [{
key: 'expression',
prompt: 'What do you want to answer?',
type: 'string'
}]
args: [
{
key: 'expression',
prompt: 'What do you want to answer?',
type: 'string'
}
]
});
}
+27 -24
View File
@@ -8,41 +8,44 @@ module.exports = class StrawpollCommand extends Command {
group: 'random',
memberName: 'strawpoll',
description: 'Creates a Strawpoll with your options.',
args: [{
key: 'title',
prompt: 'What would you like the title of the Strawpoll to be?',
type: 'string',
validate: title => {
if (title.length < 200)
return true;
return `Please keep your title under 200 characters, you have ${title.length}.`;
args: [
{
key: 'title',
prompt: 'What would you like the title of the Strawpoll to be?',
type: 'string',
validate: title => {
if (title.length < 200)
return true;
return `Please keep your title under 200 characters, you have ${title.length}.`;
}
},
{
key: 'options',
prompt: 'What options do you want me pick from? Maximum of 31.',
type: 'string',
infinite: true,
validate: choice => {
if (choice.length < 160)
return true;
return `Please keep your options under 160 characters each, you have ${choice.length}.`;
}
}
}, {
key: 'choices',
prompt: 'What choices do you want me pick from? Maximum of 31.',
type: 'string',
infinite: true,
validate: choice => {
if (choice.length < 160)
return true;
return `Please keep your choices under 160 characters each, you have ${choice.length}.`;
}
}]
]
});
}
async run(msg, args) {
const { title, choices } = args;
if (choices.length < 2)
const { title, options } = args;
if (options.length < 2)
return msg.say('You provided less than two choices.');
if (choices.length > 31)
if (options.length > 31)
return msg.say('You provided more than thirty choices.');
try {
const { body } = await request
.post('https://strawpoll.me/api/v2/polls')
.send({
title: title,
options: choices
title,
options
});
return msg.say(`${body.title}\nhttp://strawpoll.me/${body.id}`);
} catch (err) {