From fec987114f0b25d76e3646ad87da157c01f715d4 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Thu, 2 Dec 2021 17:29:08 -0600 Subject: [PATCH] Make it so the user can only vote one time for each question --- src/services/twitch_handler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/twitch_handler.ts b/src/services/twitch_handler.ts index f0b9be4..fef6a3e 100644 --- a/src/services/twitch_handler.ts +++ b/src/services/twitch_handler.ts @@ -73,7 +73,11 @@ export const run_twitch = (): void => { // Check if the user is voting let match = message.match(/\((?[A-F])\i)/) - if (match && question_index != -1) { + if ( + match // choice found in message + && users[context.username] == null // user not voted yet + && question_index != -1 // quiz started + ) { let choice: string = (match as any).choice; // Update the user's answer