mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Quiz type choice
This commit is contained in:
+1
-1
@@ -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
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "30.0.0",
|
||||
"version": "30.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user