diff --git a/commands/edit-text/brony-speak.js b/commands/edit-text/brony-speak.js index a6b25545..d7e7ac73 100644 --- a/commands/edit-text/brony-speak.js +++ b/commands/edit-text/brony-speak.js @@ -6,7 +6,7 @@ module.exports = class BronySpeakCommand extends Command { constructor(client) { super(client, { name: 'brony-speak', - aliases: ['pony-speak', 'my-little-pony-speak', 'mlp-speak'], + aliases: ['pony-speak', 'my-little-pony-speak', 'mlp-speak', 'brony'], group: 'edit-text', memberName: 'brony-speak', description: 'Converts text to brony speak.', diff --git a/commands/edit-text/yoda.js b/commands/edit-text/yoda.js new file mode 100644 index 00000000..faaa0501 --- /dev/null +++ b/commands/edit-text/yoda.js @@ -0,0 +1,55 @@ +const Command = require('../../framework/Command'); +const { firstUpperCase } = require('../../util/Util'); +const pivots = ['is', 'be', 'will', 'show', 'do', 'try', 'are', 'teach', 'have', 'am']; +const ends = ['Hmmmmm.', 'Herh herh herh.', 'Yes, hmmm?']; + +module.exports = class YodaCommand extends Command { + constructor(client) { + super(client, { + name: 'yoda', + group: 'edit-text', + memberName: 'yoda', + description: 'Converts text to Yoda speak.', + args: [ + { + key: 'text', + prompt: 'What text would you like to convert to yoda speak?', + type: 'string' + } + ] + }); + } + + run(msg, { text }) { + return msg.say(this.yodaSpeak(text)); + } + + yodaSpeak(text) { + const sentences = text.split(/\?|!|\./); + const newSentences = []; + for (const sentence of sentences) { + const trimmed = sentence.trim(); + const breaks = trimmed.split(','); + const newBreaks = []; + for (const broke of breaks) { + let newText = []; + const pivoted = []; + const words = broke.split(' '); + for (let i = 0; i < words.length; i++) { + const clean = words[i].toLowerCase().replace(/[^a-z]/, '').trim(); + if (pivots.includes(clean)) { + const fixed = newText.slice(i - 1); + newText.splice(-i); + pivoted.push(fixed, clean); + } else { + newText.push(clean); + } + } + newText = newText.map((word, i) => i === 0 ? firstUpperCase(word) : word); + newBreaks.push(`${newText.join(' ').trim()} ${pivoted.join(' ').trim()}`); + } + newSentences.push(newBreaks.join(', ').trim()); + } + return `${newSentences.join('. ').trim()} ${ends[Math.floor(Math.random() * ends.length)]}`; + } +}; diff --git a/commands/events/us-election.js b/commands/events/us-election.js index 2492024b..4068d813 100644 --- a/commands/events/us-election.js +++ b/commands/events/us-election.js @@ -33,7 +33,7 @@ module.exports = class UsElectionCommand extends Command { canidate => `**${canidate.name}:** ${canidate.score} (${canidate.percentChange} in last day)` ); return msg.say(stripIndents` - __**Chances of Winning the ${year} US Presidential Election (According to Betting Markets):**__ + __**Chances of Winning the ${year} US Election:**__ ${list.join('\n')} _More detailed information is available at ._