diff --git a/README.md b/README.md index bfb00c2f..737ea464 100644 --- a/README.md +++ b/README.md @@ -260,7 +260,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 557 +Total: 558 ### Utility: @@ -314,6 +314,7 @@ Total: 557 ### Random Response: * **8-ball:** Asks your question to the Magic 8 Ball. +* **acrostic:** Creates an acrostic from any word or name. * **advice:** Responds with a random bit of advice. * **axis-cult:** Responds with a teaching of the Axis Cult. * **bunny-fact:** Responds with a random bunny fact. @@ -1187,6 +1188,7 @@ here. * create-qr-code ([QR code API](http://goqr.me/api/)) * read-qr-code ([QR code API](http://goqr.me/api/)) - [Grady Ward](https://en.wikipedia.org/wiki/Grady_Ward) + * acrostic ([Moby Word Lists](http://www.gutenberg.org/ebooks/3201)) * hangman ([Moby Word Lists](http://www.gutenberg.org/ebooks/3201)) * word ([Moby Word Lists](http://www.gutenberg.org/ebooks/3201)) * word-chain ([Moby Word Lists](http://www.gutenberg.org/ebooks/3201)) diff --git a/commands/random-res/acrostic.js b/commands/random-res/acrostic.js new file mode 100644 index 00000000..f4ccd7b3 --- /dev/null +++ b/commands/random-res/acrostic.js @@ -0,0 +1,44 @@ +const Command = require('../../structures/Command'); +const words = require('../../assets/json/word-list'); + +module.exports = class AcrosticCommand extends Command { + constructor(client) { + super(client, { + name: 'acrostic', + group: 'random-res', + memberName: 'acrostic', + description: 'Creates an acrostic from any word or name.', + credit: [ + { + name: 'Grady Ward', + url: 'https://en.wikipedia.org/wiki/Grady_Ward', + reason: 'Moby Word Lists', + reasonURL: 'http://www.gutenberg.org/ebooks/3201' + } + ], + args: [ + { + key: 'word', + prompt: 'What word do you want to use to generate the acrostic? Only letters and spaces.', + type: 'string', + max: 20, + validate: word => { + if (/^[A-Z ]+$/i.test(word)) return true; + return 'Please enter a valid word. Only letters and spaces are allowed.'; + }, + parse: word => word.toLowerCase().split('') + } + ] + }); + } + + run(msg, { word }) { + const results = []; + for (const letter of word) { + const filteredWords = wordList.filter(wrd => wrd.startsWith(letter.toLowerCase())); + const chosen = filteredWords[Math.floor(Math.random() * filteredWords.length)]; + results.push(`**${letter.toUpperCase()}**${chosen.slice(1)}`); + } + return msg.say(results.join('\n')); + } +}; diff --git a/package.json b/package.json index 5a49bc41..69c01a2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.41.0", + "version": "119.42.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {