Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow showing correct trivia question on incorrect answer #2945

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading