Change in the way choice commands work

This commit is contained in:
Daniel Odendahl Jr
2017-04-11 13:44:43 +00:00
parent 0a3d8dc6a5
commit f0ad17ab4b
6 changed files with 71 additions and 38 deletions
+20 -14
View File
@@ -10,9 +10,9 @@ module.exports = class MemeCommand extends Command {
],
group: 'imageedit',
memberName: 'meme',
description: 'Sends a Meme with text of your choice, and a background of your choice. Split first and second lines with a | (;meme facepalm I can\'t even | comprehend this)',
description: 'Sends a Meme with text of your choice, and a background of your choice. (;meme facepalm "I can\'t even" "comprehend this")',
details: '**Codes:** tenguy, afraid, older, aag, tried, biw, blb, kermit, bd, ch, cbg, wonka, cb, keanu, dsm, live, ants, doge, alwaysonbeat, ermg, facepalm, fwp, fa, fbf, fry, hipster, icanhas, crazypills, mw, noidea, regret, boat, hagrid, sohappy, captain, inigo, iw, ackbar, happening, joker, ive, ll, morpheus, mb, badchoice, mmm, jetpack, red, mordor, oprah, oag, remembers, philosoraptor, jw, patrick, rollsafe, sad-obama, sad-clinton, sadfrog, sad-bush, sad-biden, sad-boehner, saltbae, sarcasticbear, dwight, sb, ss, sf, dodgson, money, sohot, nice, awesome-awkward, awesome, awkward-awesome, awkward, fetch, success, scc, ski, officespace, interesting, toohigh, bs, center, both, winter, xy, buzz, yodawg, uno, yallgot, bad, elf, chosen',
examples: [';meme facepalm I can\'t even | comprehend this'],
examples: [';meme facepalm "I can\'t even" "comprehend this"'],
args: [{
key: 'type',
prompt: 'What meme type do you want to use?',
@@ -24,14 +24,24 @@ module.exports = class MemeCommand extends Command {
return 'Please enter a valid meme type. Use `;help meme` to view a list of types.';
}
}, {
key: 'content',
prompt: 'What should the meme content be? Split the bottom and top text of the meme with " | ".',
key: 'toprow',
prompt: 'What should the top row of the meme to be? Surround in "" for multiple words.',
type: 'string',
validate: content => {
if (content.includes(' | ') && content.match(/^[a-zA-Z0-9|.,!?'-\s]+$/)) {
validate: toprow => {
if (toprow.match(/^[a-zA-Z0-9|.,!?'-\s]+$/) && toprow.length < 101) {
return true;
}
return 'Please split your choices with ' | ' and do not use special characters.';
return 'Please do not use special characters and keep the rows under 100 characters each.';
}
}, {
key: 'bottomrow',
prompt: 'What should the bottom row of the meme to be? Surround in "" for multiple words.',
type: 'string',
validate: bottomrow => {
if (bottomrow.match(/^[a-zA-Z0-9|.,!?'-\s]+$/) && bottomrow.length < 101) {
return true;
}
return 'Please do not use special characters and keep the rows under 100 characters each.';
}
}]
});
@@ -43,13 +53,9 @@ module.exports = class MemeCommand extends Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!');
}
const type = args.type.toLowerCase();
const content = args.content;
const memeQuery = content.split(' ').join('-').split('-|-');
const toprow = memeQuery[0].split('?').join('~q');
const bottomrow = memeQuery[1].split('?').join('~q');
const toprow = args.toprow.split(' ').join('-').split('?').join('~q');
const bottomrow = args.bottomrow.split(' ').join('-').split('?').join('~q');
const link = `https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`;
if (bottomrow.length > 100) return message.say(':x: Error! Bottom text is over 100 characters!');
if (toprow.length > 100) return message.say(':x: Error! Top text is over 100 characters!');
return message.channel.sendFile(link).catch(err => message.say(':x: Error! Something went wrong!'));
return message.channel.sendFile(link).catch(() => message.say(':x: Error! Something went wrong!'));
}
};
+4 -12
View File
@@ -11,8 +11,8 @@ module.exports = class StrawpollCommand extends Command {
],
group: 'random',
memberName: 'strawpoll',
description: 'Creates a Strawpoll with your options. (;strawpoll "Who likes chips?" Me | Not Me)',
examples: [';strawpoll "Who likes chips?" Me | Not Me'],
description: 'Creates a Strawpoll with your options. (;strawpoll "Who likes chips?" "Me" "Not Me")',
examples: [';strawpoll "Who likes chips?" "Me" "Not Me"'],
args: [{
key: 'title',
prompt: 'What would you like the title of the Strawpoll to be? Surround in "" for multiple words.',
@@ -25,17 +25,9 @@ module.exports = class StrawpollCommand extends Command {
}
}, {
key: 'choices',
prompt: 'What choices do you want me pick from? Split them with " | ".',
prompt: 'What choices do you want me pick from? Surround each choice in "".',
type: 'string',
validate: content => {
if (content.includes(' | ')) {
return true;
}
if (content.length > 160) {
return 'Please limit your options to 160 characters.';
}
return 'Please split your choices with ' | '.';
}
infinite: true
}]
});
}
+4 -10
View File
@@ -9,18 +9,13 @@ module.exports = class ChooseCommand extends Command {
],
group: 'response',
memberName: 'choose',
description: 'Chooses between things. (;choose Cow | Sheep)',
examples: [';choose Cow | Sheep', ';choose Bark | Woof | Meow | Moo'],
description: 'Chooses between things. (;choose "Cow" "Sheep")',
examples: [';choose "Cow" "Sheep"', ';choose "Bark" "Woof" "Meow" "Moo"'],
args: [{
key: 'choices',
prompt: 'What choices do you want me pick from? Split them with " | ".',
prompt: 'What choices do you want me pick from? Surround each choice in "".',
type: 'string',
validate: content => {
if (content.includes(' | ')) {
return true;
}
return 'Please split your choices with ' | '.';
}
infinite: true
}]
});
}
@@ -30,7 +25,6 @@ module.exports = class ChooseCommand extends Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
let choices = args.choices;
choices = choices.split(' | ');
choices = choices[Math.floor(Math.random() * choices.length)];
return message.say(`I choose ${choices}!`);
}