Skip to content

Commit

Permalink
Merge pull request #2945 from dennisrijsdijk/feat/reveal-correct-triv…
Browse files Browse the repository at this point in the history
…ia-answer

feat: allow showing correct trivia question on incorrect answer
  • Loading branch information
zunderscore authored Jan 1, 2025
2 parents a466bbd + fa31924 commit a350912
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/backend/games/builtin/trivia/trivia-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ twitchListeners.events.on("chat-message", async (data) => {
if (!currentQuestion) {
return;
}
const { username, question, wager, winningsMultiplier, currencyId, chatter } = currentQuestion;
const { username, question, wager, winningsMultiplier, currencyId, chatter, postCorrectAnswer } = currentQuestion;
//ensure chat is from question user
if (username !== chatMessage.username) {
return;
Expand Down Expand Up @@ -69,12 +69,12 @@ twitchListeners.events.on("chat-message", async (data) => {

await twitchChat.sendChatMessage(`${chatMessage.userDisplayName ?? username}, that is correct! You have won ${util.commafy(winnings)} ${currency.name}`, null, chatter);
} else {
await twitchChat.sendChatMessage(`Sorry ${chatMessage.userDisplayName ?? username}, that is incorrect. Better luck next time!`, null, chatter);
await twitchChat.sendChatMessage(`Sorry ${chatMessage.userDisplayName ?? username}, that is incorrect.${postCorrectAnswer ? ` The correct answer was ${question.answers[question.correctIndex - 1]}.` : ""} Better luck next time!`, null, chatter);
}
clearCurrentQuestion();
});

const cooldownCache = new NodeCache({checkperiod: 5});
const cooldownCache = new NodeCache({ checkperiod: 5 });

const TRIVIA_COMMAND_ID = "firebot:trivia";

Expand Down Expand Up @@ -237,7 +237,8 @@ const triviaCommand = {
wager: wagerAmount,
winningsMultiplier: winningsMultiplier,
currencyId: currencyId,
chatter: chatter
chatter: chatter,
postCorrectAnswer: triviaSettings.settings.chatSettings.postCorrectAnswer
};

const answerTimeout = triviaSettings.settings.questionSettings.answerTime;
Expand Down
10 changes: 10 additions & 0 deletions src/backend/games/builtin/trivia/trivia.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,16 @@ module.exports = {
validation: {
required: true
}
},
postCorrectAnswer: {
type: "boolean",
title: "Post Correct Answer",
tip: "Post the correct answer in chat if the viewer answered incorrectly.",
default: false,
sortRank: 3,
validation: {
required: true
}
}
}
}
Expand Down

0 comments on commit a350912

Please sign in to comment.