diff --git a/assets/json/math-game.json b/assets/json/math-game.json index aecc417c..839d8ea3 100644 --- a/assets/json/math-game.json +++ b/assets/json/math-game.json @@ -1,8 +1,25 @@ { - "operations": [ - "+", - "-", - "*" + "operations": { + "easy": [ + "+", + "-" + ], + "medium": [ + "+", + "-" + ], + "hard": [ + "-", + "*" + ], + "extreme": [ + "-", + "*" + ], + "impossible": [ + "*", + "/" + ] ], "difficulties": [ "easy", diff --git a/commands/games/math-game.js b/commands/games/math-game.js index a4dc89d4..645a7586 100644 --- a/commands/games/math-game.js +++ b/commands/games/math-game.js @@ -28,7 +28,7 @@ module.exports = class MathGameCommand extends Command { async run(msg, args) { const { difficulty } = args; - const operation = operations[Math.floor(Math.random() * operations.length)]; + const operation = operations[difficulty][Math.floor(Math.random() * operations.length)]; const value1 = Math.floor(Math.random() * maxValues[difficulty]) + 1; const value2 = Math.floor(Math.random() * maxValues[difficulty]) + 1; const expression = `${value1} ${operation} ${value2}`; diff --git a/commands/games/quiz.js b/commands/games/quiz.js index 1085e736..4dde10d6 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -3,6 +3,7 @@ const { MessageEmbed } = require('discord.js'); const { stripIndents } = require('common-tags'); const snekfetch = require('snekfetch'); const { shuffle, list } = require('../../structures/Util'); +const difficulties = ['easy', 'medium', 'hard']; module.exports = class QuizCommand extends Command { constructor(client) { @@ -18,25 +19,36 @@ module.exports = class QuizCommand extends Command { key: 'type', prompt: 'Which type of question would you like to have? `multiple` or `boolean`.', type: 'string', - default: 'boolean', validate: type => { if (['multiple', 'boolean'].includes(type.toLowerCase())) return true; return 'Please enter either `multiple` or `boolean`.'; }, parse: type => type.toLowerCase() + }, + { + key: 'difficulty', + prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`, + type: 'string', + default: '', + validate: difficulty => { + if (difficulties.includes(difficulty.toLowerCase())) return true; + return `The difficulty must be one of: ${difficulties.join(', ')}`; + }, + parse: difficulty => difficulty.toLowerCase() } ] }); } async run(msg, args) { - const { type } = args; + const { type, difficulty } = args; const { body } = await snekfetch .get('https://opentdb.com/api.php') .query({ amount: 1, type, - encode: 'url3986' + encode: 'url3986', + difficulty }); if (!body.results) return msg.say('Oh no, a question could not be fetched. Try again later!'); const answers = body.results[0].incorrect_answers.map(answer => decodeURIComponent(answer.toLowerCase())); diff --git a/commands/random-res/today.js b/commands/random-res/today.js index 7e887fb3..64d4eb34 100644 --- a/commands/random-res/today.js +++ b/commands/random-res/today.js @@ -13,34 +13,20 @@ module.exports = class TodayCommand extends Command { clientPermissions: ['EMBED_LINKS'], args: [ { - key: 'month', - prompt: 'Which month do you want events for?', - type: 'integer', - default: '', - validate: month => { - if (month < 13 && month > 0) return true; - return 'Please enter a valid month.'; - } - }, - { - key: 'day', - prompt: 'Which day do you want events for?', - type: 'integer', - default: '', - validate: day => { - if (day < 32 && day > 0) return true; - return 'Please enter a valid day.'; - } + key: 'date', + prompt: 'What date do you want events for? Month/Day format.', + type: 'string', + default: '' } ] }); } async run(msg, args) { - const { month, day } = args; + const { date } = args; try { const { text } = await snekfetch - .get(`http://history.muffinlabs.com/date${month && day ? `/${month}/${day}` : ''}`); + .get(`http://history.muffinlabs.com/date${date ? `/${date}` : ''}`); const body = JSON.parse(text); const events = body.data.Events; const event = events[Math.floor(Math.random() * events.length)]; diff --git a/package.json b/package.json index c82a5f94..b5d1e8f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "31.1.2", + "version": "31.1.3", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {