mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Let's Try This Crazy Stuff
This commit is contained in:
+25
-24
@@ -21,29 +21,30 @@ module.exports = class QuizCommand extends commando.Command {
|
|||||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||||
}
|
}
|
||||||
console.log("[Command] " + message.content);
|
console.log("[Command] " + message.content);
|
||||||
return request
|
try {
|
||||||
.get('http://jservice.io/api/random')
|
let response = await request
|
||||||
.query({
|
.get('http://jservice.io/api/random')
|
||||||
count: 1
|
.query({
|
||||||
})
|
count: 1
|
||||||
.then(function(response) {
|
|
||||||
const embed = new Discord.RichEmbed()
|
|
||||||
.setTitle('You have **fifteen** seconds to answer this question:')
|
|
||||||
.setDescription(`**Category: ${response.body[0].category}**\n${response.body[0].question}`);
|
|
||||||
message.channel.sendEmbed(embed).then(() => {
|
|
||||||
message.channel.awaitMessages(res => res.content.toLowerCase() === response.body[0].answer.toLowerCase() && res.author.id === message.author.id, {
|
|
||||||
max: 1,
|
|
||||||
time: 15000,
|
|
||||||
errors: ['time'],
|
|
||||||
}).then((collected) => {
|
|
||||||
return message.channel.send(`Good Job! You won!`);
|
|
||||||
}).catch(() => {
|
|
||||||
return message.channel.send(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${response.body[0].answer}`);
|
|
||||||
});
|
|
||||||
}).catch(function(err) {
|
|
||||||
console.log(err);
|
|
||||||
return message.channel.send(":x: Error! Something went wrong!");
|
|
||||||
});
|
});
|
||||||
});
|
const embed = new Discord.RichEmbed()
|
||||||
|
.setTitle('You have **fifteen** seconds to answer this question:')
|
||||||
|
.setDescription(`**Category: ${response.body[0].category}**\n${response.body[0].question}`);
|
||||||
|
let embededMessage = await message.channel.sendEmbed(embed);
|
||||||
|
try {
|
||||||
|
let collected = await message.channel.awaitMessages(res => res.content.toLowerCase() === response.body[0].answer.toLowerCase() && res.author.id === message.author.id, {
|
||||||
|
max: 1,
|
||||||
|
time: 15000,
|
||||||
|
errors: ['time']
|
||||||
|
});
|
||||||
|
let winnerMes = await message.channel.send(`Good Job! You won!`);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
let loserMes = await message.channel.send(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${response.body[0].answer}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
let errorMessage = await message.channel.send(":x: Error! Something went wrong!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user