From 3f89e01b326fc03983172d08e5bb3b796fbc545f Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 15 Jul 2018 02:31:36 +0000 Subject: [PATCH] Scrabble Score Command --- README.md | 3 ++- assets/json/scrabble-score.json | 29 ++++++++++++++++++++++++++++ commands/search/scrabble-score.js | 32 +++++++++++++++++++++++++++++++ package.json | 2 +- 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 assets/json/scrabble-score.json create mode 100644 commands/search/scrabble-score.js diff --git a/README.md b/README.md index 951604dd..15b69067 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can invite the bot to your server using Be sure to also join the [home server](https://discord.gg/sbMe32W) for information and support. -## Commands (294) +## Commands (295) ### Utility: * **prefix**: Shows or sets the command prefix. @@ -160,6 +160,7 @@ information and support. * **rule-of-the-internet**: Responds with a rule of the internet. * **rule34**: Responds with an image from Rule34, with optional query. * **safebooru**: Responds with an image from Safebooru, with optional query. +* **scrabble-score**: Responds with the scrabble score of a word. * **stack-overflow**: Searches Stack Overflow for your query. * **steam**: Searches Steam for your query. * **stocks**: Responds with the current stocks for a specific symbol. diff --git a/assets/json/scrabble-score.json b/assets/json/scrabble-score.json new file mode 100644 index 00000000..5565490a --- /dev/null +++ b/assets/json/scrabble-score.json @@ -0,0 +1,29 @@ +{ + "a": 1, + "b": 3, + "c": 3, + "d": 2, + "e": 1, + "f": 4, + "g": 2, + "h": 4, + "i": 1, + "j": 8, + "k": 5, + "l": 1, + "m": 3, + "n": 1, + "o": 1, + "p": 3, + "q": 10, + "r": 1, + "s": 1, + "t": 1, + "u": 1, + "v": 4, + "w": 4, + "x": 8, + "y": 4, + "z": 10, + " ": 0 +} diff --git a/commands/search/scrabble-score.js b/commands/search/scrabble-score.js new file mode 100644 index 00000000..a2286b12 --- /dev/null +++ b/commands/search/scrabble-score.js @@ -0,0 +1,32 @@ +const Command = require('../../structures/Command'); +const letters = require('../../assets/json/roman-numeral'); + +module.exports = class ScrabbleScoreCommand extends Command { + constructor(client) { + super(client, { + name: 'scrabble-score', + aliases: ['scrabble'], + group: 'number-edit', + memberName: 'scrabble-score', + description: 'Responds with the scrabble score of a word.', + args: [ + { + key: 'word', + prompt: 'What word would you like to get the scrabble score of?', + type: 'string', + validate: word => { + if (/[A-Za-z ]/i.test(word.toLowerCase())) return true; + return 'Invalid word, please only use A-Z and space.'; + }, + parse: word => word.toLowerCase() + } + ] + }); + } + + run(msg, { word }) { + let score = 0; + for (const letter of word.split('')) score += letters[letter]; + return msg.reply(score); + } +}; diff --git a/package.json b/package.json index 842cf8d4..595285ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "84.4.2", + "version": "84.5.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {