diff --git a/assets/json/dating.json b/assets/json/dating.json deleted file mode 100644 index fed00c15..00000000 --- a/assets/json/dating.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - "Perfect match! You guys were made for each other!", - "Literally 100% compatability. What are you waiting for?", - "This is strange, I've never seen such a high compatability before.", - "The person of your dreams right here.", - "Come on, send that friend request. You know you want this.", - "You sure you can wait? This is a once-in-a-lifetime opprotunity.", - "Going fast, get it while it's hot! Oh wait... That's always.", - "You won't regret this. I promise.", - "Trust me, you've never seen such a perfect human being.", - "This may be a joke command, but you know you still want to try." -] diff --git a/assets/json/google-feud.json b/assets/json/google-feud.json deleted file mode 100644 index 7b08399a..00000000 --- a/assets/json/google-feud.json +++ /dev/null @@ -1,101 +0,0 @@ -[ - "Are cats", - "Are dogs", - "Are birds", - "Do cats", - "Do dogs", - "Do birds", - "Am I", - "Is Google", - "Is it bad to", - "What is the best way to", - "Can cats", - "Can I", - "Can you", - "Is it okay to", - "Will I die if", - "Does the world hate", - "Does everyone hate", - "Can you code", - "JavaScript is", - "Schools are", - "Is Discord", - "What is", - "Where is", - "Did dinosaurs", - "When will", - "Is anime", - "What anime is", - "Am I part", - "Does Google know", - "Is the world", - "What game is", - "What game has", - "Is net neutrality", - "What is the worst", - "What is the best", - "Is Kingdom Hearts", - "Can humans", - "Is chocolate", - "Are cameras", - "Who is the most", - "Who is the least", - "Am I going to pass", - "Google is", - "Can you eat", - "Eat pant", - "Are computers", - "Is it legal to", - "Am I allowed to", - "Is it possible to", - "Can I have", - "Is Neopets", - "Can I go", - "Can you die from", - "Should I", - "Will I die", - "Do people hate", - "Do people love", - "Am I in", - "Am I going to", - "Are my friends", - "Does my girlfriend", - "Does my boyfriend", - "Is my girlfriend", - "Is my boyfriend", - "What is the worst way to", - "Is there a limit on", - "What is the maximum", - "What is the minimum", - "Is the government", - "Are LEGOs", - "Memes are", - "Are memes", - "How do I get to", - "What website has", - "Is Discord better", - "How do I", - "How do you", - "Is it healthy to", - "Is it harmful to", - "Google", - "What is the best site for", - "Is it illegal to", - "Are lawyers", - "Does Discord", - "Can Discord bots", - "Who is the richest", - "Is the internet", - "Should I stay", - "On what day is", - "Do you need money to get", - "Are cats really", - "Are dogs really", - "Are there more", - "Is Twitter", - "Can I play", - "Is it right to", - "Is it wrong to", - "Discord is", - "Is 100" -] diff --git a/commands/games-sp/google-feud.js b/commands/games-sp/google-feud.js index aa804e24..5ea62f86 100644 --- a/commands/games-sp/google-feud.js +++ b/commands/games-sp/google-feud.js @@ -1,8 +1,8 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); const { MessageEmbed } = require('discord.js'); -const { formatNumber } = require('../../util/Util'); -const questions = require('../../assets/json/google-feud'); +const { formatNumber, list } = require('../../util/Util'); +const categories = ['qotd', 'culture', 'people', 'names', 'questions']; module.exports = class GoogleFeudCommand extends Command { constructor(client) { @@ -20,25 +20,30 @@ module.exports = class GoogleFeudCommand extends Command { { name: 'Google Feud', url: 'http://www.googlefeud.com/', - reason: 'Original Game' + reason: 'Question Data, Original Game' } ], args: [ { - key: 'question', - prompt: 'What question do you want to use for the game?', + key: 'category', + prompt: `What category do you want to use for the game? Either ${list(categories, 'or')}.`, type: 'string', - default: () => questions[Math.floor(Math.random() * questions.length)] + oneOf: categories, + parse: category => category.toLowerCase() } ] }); + + this.questions = null; } - async run(msg, { question }) { + async run(msg, { category }) { const current = this.client.games.get(msg.channel.id); if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`); this.client.games.set(msg.channel.id, { name: this.name }); try { + if (!this.questions) await this.fetchQuestions(); + const question = this.questions[category][Math.floor(Math.random() * this.questions[category].length)]; const suggestions = await this.fetchSuggestions(question); if (!suggestions) return msg.say('Could not find any results.'); const display = new Array(suggestions.length).fill('???'); @@ -88,6 +93,15 @@ module.exports = class GoogleFeudCommand extends Command { return suggestions.map(suggestion => suggestion.toLowerCase().replace(question.toLowerCase(), '').trim()); } + async fetchQuestions() { + if (this.questions) return this.questions; + const { body } = await request.get('https://www.googlefeud.com/autocomplete/js/questions-en.json'); + const questions = {}; + for (const category of categories) questions[category] = body[category]; + this.questions = questions; + return this.questions; + } + makeEmbed(question, tries, suggestions, display) { const embed = new MessageEmbed() .setColor(0x005AF0) diff --git a/package.json b/package.json index 84040808..ab7c559d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "137.0.0", + "version": "137.0.1", "description": "Your personal server companion.", "main": "Xiao.js", "private": true,