@@ -86,13 +86,17 @@ async function play(message, bot, send, trivia) {
8686 incorrect_answers = incorrect_answers . map ( s => h2p ( s ) ) ;
8787 incorrect_answers . push ( correct_answer ) ;
8888 incorrect_answers = shuffle ( incorrect_answers ) ;
89+ let answers = { } ;
90+ for ( let i = 0 ; i < answers . length ; i ++ ) {
91+ answers [ i + 1 ] = incorrect_answers [ i ] ;
92+ }
8993 let embed = new bot . embed ( )
9094 embed . title = "`Trivia`"
91- embed . addField ( "Question" , h2p ( question ) )
92- . addField ( "Category" , category )
95+ embed . addField ( "Category" , category )
9396 . addField ( "Difficulty" , difficulty )
9497 . addField ( "Reward" , worth + ":dollar:" )
95- . addField ( "Choices" , "**" + incorrect_answers . join ( ", " ) + "**" )
98+ . addField ( "Question" , h2p ( question ) )
99+ . addField ( "Choices" , "**" + Object . entries ( answers ) . map ( ( [ k , p ] ) => k + ". " + p ) . join ( " - " ) + "**" )
96100 . setFooter ( "You have 20 seconds to answer." )
97101 . setColor ( "#4DD0D9" )
98102 . setAuthor ( message . guild . name , message . guild . iconURL )
@@ -103,9 +107,11 @@ async function play(message, bot, send, trivia) {
103107 let guessed = { } ;
104108 let collector = message . channel . createMessageCollector ( m => {
105109 if ( m . author . bot ) return false
110+ let guess = parseInt ( m . content ) ;
111+ if ( guess === null ) return false ;
106112 if ( guessed [ m . author . id ] ) return false ;
107113 guessed [ m . author . id ] = true ;
108- if ( checkAnswer ( correct_answer , m . content ) ) {
114+ if ( checkAnswer ( correct_answer , answers , guess ) ) {
109115 collector . stop ( "WINNED" )
110116 win ( bot , message , m . author , worth )
111117 }
@@ -146,11 +152,11 @@ function shuffle (array) {
146152 return array ;
147153}
148154
149- function checkAnswer ( correct , input ) {
150- let c = correct . toLowerCase ( )
151- let i = input . toLowerCase ( )
152- if ( stringSim . compareTwoStrings ( c , i ) > .7 ) return true
153- else return false
155+ function checkAnswer ( correct , answers , input ) {
156+ let a = answers [ input + 1 ] ;
157+ if ( ! a ) return false ;
158+ return a === correct ;
159+
154160}
155161
156162function genUrl ( d , c ) {
0 commit comments