diff --git a/XiaoBot.js b/XiaoBot.js index 30e89f86..65babb28 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -110,7 +110,7 @@ client.on('guildDelete', async guild => { dBotsOrg(count, client.user.id); }); -client.setTimeout(() => process.exit(0), 7200000); +client.setTimeout(() => process.exit(0), 7.2e+6); client.login(TOKEN); diff --git a/commands/games/quiz.js b/commands/games/quiz.js index 2bf924a7..58686f47 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -11,19 +11,34 @@ module.exports = class QuizCommand extends Command { group: 'games', memberName: 'quiz', description: 'Answer a true/false quiz question.', - clientPermissions: ['EMBED_LINKS'] + clientPermissions: ['EMBED_LINKS'], + args: [ + { + 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() + } + ] }); } - async run(msg) { + async run(msg, args) { + const { type } = args; const { body } = await snekfetch .get('https://opentdb.com/api.php') .query({ amount: 1, - type: 'boolean', + type, encode: 'url3986' }); - const answer = body.results[0].correct_answer.toLowerCase(); + if (!body.results.length) return msg.say('Oh no, a question could not be fetched. Try again later!'); + const answer = decodeURIComponent(body.results[0].correct_answer.toLowerCase()); const embed = new MessageEmbed() .setTitle('You have 15 seconds to answer this question:') .setDescription(stripIndents` diff --git a/package.json b/package.json index d9bff9d7..c7accdb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "30.0.0", + "version": "30.1.0", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {