@ -258,9 +258,10 @@ async function training(subject, interaction) {
. post ( "https://scibowldb.com/api/questions/random" , { categories : categoryArray } )
. post ( "https://scibowldb.com/api/questions/random" , { categories : categoryArray } )
. then ( ( res ) => {
. then ( ( res ) => {
data = res . data . question ;
data = res . data . question ;
console . log ( ` ${ interaction . user . tag } -- ${ data . tossup_question } -- ${ data . tossup_answer } \n ` ) ;
const tossupQuestion = data . tossup_question ;
const tossupAnswer = data . tossup_answer ;
const messageFilter = ( m ) => m . author . id === authorId ;
const messageFilter = ( m ) => m . author . id === authorId ;
interaction . reply ( { content : data . tossup_q uestion + ` \n \n ||Source: ${ data . uri } || ` } )
interaction . reply ( { content : tossupQ uestion + ` \n \n ||Source: ${ data . uri } || ` } )
. then ( ( ) => {
. then ( ( ) => {
interaction . channel . awaitMessages ( {
interaction . channel . awaitMessages ( {
messageFilter ,
messageFilter ,
@ -273,7 +274,7 @@ async function training(subject, interaction) {
if ( data . tossup_format === "Multiple Choice" ) {
if ( data . tossup_format === "Multiple Choice" ) {
if (
if (
answerMsg . content . charAt ( 0 ) . toLowerCase ( ) ===
answerMsg . content . charAt ( 0 ) . toLowerCase ( ) ===
data . tossup_a nswer. charAt ( 0 ) . toLowerCase ( )
tossupA nswer. charAt ( 0 ) . toLowerCase ( )
) {
) {
predicted = "correct" ;
predicted = "correct" ;
} else {
} else {
@ -282,7 +283,7 @@ async function training(subject, interaction) {
} else {
} else {
if (
if (
answerMsg . content . toLowerCase ( ) ===
answerMsg . content . toLowerCase ( ) ===
data . tossup_a nswer. toLowerCase ( )
tossupA nswer. toLowerCase ( )
) {
) {
predicted = "correct" ;
predicted = "correct" ;
} else {
} else {
@ -297,7 +298,7 @@ async function training(subject, interaction) {
} else {
} else {
const overrideEmbed = new Discord . MessageEmbed ( )
const overrideEmbed = new Discord . MessageEmbed ( )
. setAuthor ( answerMsg . author . tag , answerMsg . author . displayAvatarURL ( ) )
. setAuthor ( answerMsg . author . tag , answerMsg . author . displayAvatarURL ( ) )
. addField ( "Correct answer" , ` \` ${ data . tossup_a nswer} \` ` )
. addField ( "Correct answer" , ` \` ${ tossupA nswer} \` ` )
. setDescription ( ` It seems your answer was incorrect. Please react with <:override:842778128966615060> to override your answer if you think you got it right. ` )
. setDescription ( ` It seems your answer was incorrect. Please react with <:override:842778128966615060> to override your answer if you think you got it right. ` )
. setColor ( "#ffffff" )
. setColor ( "#ffffff" )
. setTimestamp ( ) ;
. setTimestamp ( ) ;
@ -420,12 +421,12 @@ function showLeaderboard(interaction) {
for ( let i = 0 ; i < 10 ; i ++ ) {
for ( let i = 0 ; i < 10 ; i ++ ) {
messageContent += ` ${ i + 1 } : <@ ${ obj [ i ] . authorID } >: ${ obj [ i ] . score } \n ` ; // Loop through each user and add their name and score to leaderboard content
messageContent += ` ${ i + 1 } : <@ ${ obj [ i ] . authorID } >: ${ obj [ i ] . score } \n ` ; // Loop through each user and add their name and score to leaderboard content
}
}
interaction . reply (
const leaderboardEmbed = new Discord . MessageEmbed ( )
new Discord . MessageEmbed ( )
. setTitle ( "Top Ten!" )
. setTitle ( "Top Ten!" )
. setDescription ( messageContent )
. setDescription ( messageContent )
. setColor ( "#ffffff" )
. setColor ( "#ffffff" )
) ;
interaction . reply ( { embeds : [ leaderboardEmbed ] } ) ;
} ) ;
} ) ;
}
}