mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 15:58:06 +02:00
Fix shuffling so that B isn't always correct in boolean
This commit is contained in:
@@ -58,11 +58,11 @@ module.exports = class QuizCommand extends Command {
|
||||
const answers = body.results[0].incorrect_answers.map(answer => decodeURIComponent(answer.toLowerCase()));
|
||||
const correct = decodeURIComponent(body.results[0].correct_answer.toLowerCase());
|
||||
answers.push(correct);
|
||||
const answerList = type === 'boolean' ? answers : shuffle(answers);
|
||||
const shuffled = shuffle(answers);
|
||||
await msg.say(stripIndents`
|
||||
**You have 15 seconds to answer this question.**
|
||||
${decodeURIComponent(body.results[0].question)}
|
||||
${answerList.map((answer, i) => `**${choices[i]}**. ${answer}`).join('\n')}
|
||||
${shuffled.map((answer, i) => `**${choices[i]}**. ${answer}`).join('\n')}
|
||||
`);
|
||||
const filter = res => res.author.id === msg.author.id && choices.includes(res.content.toUpperCase());
|
||||
const msgs = await msg.channel.awaitMessages(filter, {
|
||||
@@ -70,7 +70,7 @@ module.exports = class QuizCommand extends Command {
|
||||
time: 15000
|
||||
});
|
||||
if (!msgs.size) return msg.say(`Sorry, time is up! It was ${correct}.`);
|
||||
const win = answerList[choices.indexOf(msgs.first().content.toUpperCase())] === correct;
|
||||
const win = shuffled[choices.indexOf(msgs.first().content.toUpperCase())] === correct;
|
||||
if (!win) return msg.say(`Nope, sorry, it's ${correct}.`);
|
||||
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||
} catch (err) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "66.4.0",
|
||||
"version": "66.4.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user