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
+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) {