Quiz type choice

This commit is contained in:
Daniel Odendahl Jr
2017-08-13 15:43:21 +00:00
parent 71c9691419
commit 01e73c5d85
3 changed files with 21 additions and 6 deletions
+1 -1
View File
@@ -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);
+19 -4
View File
@@ -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`
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "30.0.0",
"version": "30.1.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {