File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -356,27 +356,21 @@ export async function handleTwoPlayerMatchVoting(
356356 const allVoted =
357357 participants . length > 0 && totalVotes === participants . length
358358
359+ // Check for winner
360+ let winner : number | undefined
359361 if ( allVoted ) {
360- // Check majority
361362 const majority = Math . floor ( participants . length / 2 ) + 1
362- let winner : number | undefined
363363 for ( let i = 0 ; i < voteArray . length ; i ++ ) {
364364 if ( voteArray [ i ] . votes . length >= majority ) {
365365 winner = i + 1 // Teams start at 1
366366 }
367367 }
368-
369- if ( winner ) {
370- await onComplete ( interaction , winner )
371- return
372- }
373368 }
374369
375370 try {
376- // Acknowledge the interaction first
371+ // Always update the message to show the vote immediately
377372 await interaction . deferUpdate ( )
378373
379- // Delete the old message and send a new one
380374 const channel = interaction . channel as GuildChannel
381375 const components = interaction . message . components
382376 await interaction . message . delete ( )
@@ -389,6 +383,12 @@ export async function handleTwoPlayerMatchVoting(
389383
390384 setLastWinVoteMessage ( channel . id , newMessage . id )
391385 }
386+
387+ // AFTER showing the vote, process the winner (this does the heavy work)
388+ if ( winner ) {
389+ await onComplete ( interaction , winner )
390+ return
391+ }
392392 } catch ( err ) {
393393 console . error ( 'Failed to update voting message:' , err )
394394 }
You can’t perform that action at this time.
0 commit comments