Acrostic Command

This commit is contained in:
Dragon Fire
2020-11-09 17:58:53 -05:00
parent 8845ea2d4d
commit 313d176ef0
3 changed files with 48 additions and 2 deletions
+3 -1
View File
@@ -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))
+44
View File
@@ -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'));
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "119.41.0",
"version": "119.42.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {