mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 16:55:55 +00:00
trivia: tldr, dont push into prod without testing
This commit is contained in:
parent
4572fb18ed
commit
a7255119f3
1 changed files with 4 additions and 9 deletions
|
@ -94,6 +94,9 @@ module.exports = {
|
||||||
const incorrectAnswers = triviaQuestion.incorrect_answers.map(decode);
|
const incorrectAnswers = triviaQuestion.incorrect_answers.map(decode);
|
||||||
let allAnswers = [...incorrectAnswers, correctAnswer];
|
let allAnswers = [...incorrectAnswers, correctAnswer];
|
||||||
|
|
||||||
|
// Declare answerMap before any conditions
|
||||||
|
let answerMap = {};
|
||||||
|
|
||||||
// Handle True/False questions specifically
|
// Handle True/False questions specifically
|
||||||
if (triviaQuestion.type === "boolean") {
|
if (triviaQuestion.type === "boolean") {
|
||||||
// Always keep "True" as option 1 and "False" as option 2
|
// Always keep "True" as option 1 and "False" as option 2
|
||||||
|
@ -102,21 +105,13 @@ module.exports = {
|
||||||
// Shuffle answers for other types of questions
|
// Shuffle answers for other types of questions
|
||||||
allAnswers = allAnswers.sort(() => Math.random() - 0.5);
|
allAnswers = allAnswers.sort(() => Math.random() - 0.5);
|
||||||
|
|
||||||
// Create a mapping of numbers to answers
|
// Assign the map without redeclaring
|
||||||
answerMap = allAnswers.reduce((map, answer, index) => {
|
answerMap = allAnswers.reduce((map, answer, index) => {
|
||||||
map[index + 1] = answer;
|
map[index + 1] = answer;
|
||||||
return map;
|
return map;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
allAnswers = allAnswers.sort(() => Math.random() - 0.5); // Shuffle answers
|
|
||||||
|
|
||||||
// Create a mapping of numbers to answers
|
|
||||||
const answerMap = allAnswers.reduce((map, answer, index) => {
|
|
||||||
map[index + 1] = answer;
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
// Create an embed with the trivia question and numbered options
|
// Create an embed with the trivia question and numbered options
|
||||||
const triviaEmbed = new EmbedBuilder()
|
const triviaEmbed = new EmbedBuilder()
|
||||||
.setColor("#0099ff")
|
.setColor("#0099ff")
|
||||||
|
|
Loading…
Reference in a new issue