if ( gamedatabase[key].user2points === gamedatabase[key].user1points ) { r = await gamechannel.send({ content: `**It's a tie!**`, }); let kdb; let boolhit1 = false let boolhit2 = false let user = gamedatabase[key].user1; gamechannel.send({ content: `**A new round is starting!**`, }); kdb = await gamechannel.send({ components: [gamerow1, gamerow2], ephemeral: false, content: `For the next upcoming rounds, refer to this message for selecting buttons. Please select one of the buttons below to indicate where you want to shoot! (You have exactly **10s** to make a decision)`, }); const filter1 = i => i.member.id !== client.user.id const collector5 = kdb.createMessageComponentCollector({ filter: filter1, componentType: "BUTTON", max: 50 }); let counter = 1; let ender = 1; let z; let g; let x; let done = false; let rk; console.log(kdb) rk = await gamechannel.send({content: `<@${gamedatabase[key].user1}> Please use the buttons above to start as an attacker!`}) collector5.on("collect", async (i) => { boolhit1 = false boolhit2 = false console.log(boolhit1) console.log(boolhit2) console.log(done) if(boolhit1 && boolhit2 || !boolhit1 && !boolhit2 || !done){ rk = await gamechannel.send({content: `<@${gamedatabase[key].user1}> Please use the buttons above to start as an attacker!`}) console.log("yes") if(ender % 2 !== 0){ if(counter % 2 == 1){ if (i.customId === `${key}-bottomleftshoot`) { status = true; shootingposition = "bottomleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Left**`}) } if (i.customId === `${key}-bottomrightshoot`) { status = true; shootingposition = "bottomright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Right**`}) } if (i.customId === `${key}-toprightshoot`) { status = true; shootingposition = "topright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Right**`}) } if (i.customId === `${key}-topleftshoot`) { status = true; shootingposition = "topleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Left**`}) } if (i.customId === `${key}-topmiddleshoot`) { status = true; shootingposition = "topmiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Middle**`}) } if (i.customId === `${key}-bottommiddleshoot`) { status = true; shootingposition = "bottommiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Middle**`}) } counter++; z = await gamechannel.send({ components: [gamerow3, gamerow4], ephemeral: false, content: `<@${gamedatabase[key].user1}>, you have successfully chosen a position!\n\n<@${gamedatabase[key].user2}> your turn to play as a keeper! Please use the buttons below to select a position! You have **10s** to answer!`, }) }else{ if (i.customId === `${key}-bottomleftkeep`) { status = true; keeperposition = "bottomleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Left**`}) } if (i.customId === `${key}-topleftkeep`) { status = true; keeperposition = "topleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Left**`}) } if (i.customId === `${key}-bottomrightkeep`) { status = true; keeperposition = "bottomright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Right**`}) } if (i.customId === `${key}-toprightkeep`) { status = true; keeperposition = "topright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Right**`}) } if (i.customId === `${key}-topmiddlekeep`) { status = true; keeperposition = "topmiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Middle**`}) } if (i.customId === `${key}-bottommiddlekeep`) { status = true; keeperposition = "bottommiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Middle**`}) } counter++; x = await gamechannel.send({ components: [], ephemeral: false, content: `<@${gamedatabase[key].user2}>, you have successfully chosen a position!`, }); if (shootingposition === keeperposition) { ender++ g = await gamechannel.send({ content: `<@${gamedatabase[key].user1}> aligned the ball and shoots to the **${shootingposition}**!\n<@${gamedatabase[key].user2}> dives to the **${keeperposition}**!\n\n<@${gamedatabase[key].user2}> saves the goal!\nCurrent Score: **<@${gamedatabase[key].user1}>-<@${gamedatabase[key].user2}> : ${gamedatabase[key].user1points}-${gamedatabase[key].user2points}**\nhttps://cdn.discordapp.com/attachments/1026610112175017987/1039709526225596516/Assets_Save_v1.gif`, }); } else { ender++ boolhit1 = true gamedatabase[key].user1points++; fs.writeFileSync( "./gamedatabase.json", JSON.stringify(gamedatabase), (err) => { if (err) console.log(err); } ); g = await gamechannel.send({ content: `<@${gamedatabase[key].user1}> aligned the ball and shoots to the **${shootingposition}**!\n<@${gamedatabase[key].user2}> dives to the **${keeperposition}**!\n\n<@${gamedatabase[key].user1}> scores the goal!\nCurrent Score: **<@${gamedatabase[key].user1}>-<@${gamedatabase[key].user2}> : ${gamedatabase[key].user1points}-${gamedatabase[key].user2points}**`, }); gamechannel.send({content: `https://cdn.discordapp.com/attachments/1028084538020200468/1042927320144552016/Asset_Goal_v1_2.gif`}) } } }else{ g= await gamechannel.send({ components: [gamerow1, gamerow2], ephemeral: false, content: `<@${gamedatabase[key].user2}>, you are beginning as a striker again! Please select one of the buttons below to indicate where you want to shoot! (You have exactly **10s** to make a decision)`, }); if(counter % 2 == 1){ if (i.customId === `${key}-bottomleftshoot`) { status = true; shootingposition = "bottomleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Left**`}) } if (i.customId === `${key}-bottomrightshoot`) { status = true; shootingposition = "bottomright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Right**`}) } if (i.customId === `${key}-toprightshoot`) { status = true; shootingposition = "topright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Right**`}) } if (i.customId === `${key}-topleftshoot`) { status = true; shootingposition = "topleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Left**`}) } if (i.customId === `${key}-topmiddleshoot`) { status = true; shootingposition = "topmiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Middle**`}) } if (i.customId === `${key}-bottommiddleshoot`) { status = true; shootingposition = "bottommiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Middle**`}) } counter++; y = await gamechannel.send({ components: [gamerow3, gamerow4], ephemeral: false, content: `<@${gamedatabase[key].user2}>, you have successfully chosen a position!\n\n<@${gamedatabase[key].user1}> your turn to play as a keeper! Please use the buttons below to select a position! You have **10s** to answer!`, }) }else{ if (i.customId === `${key}-bottomleftkeep`) { status = true; keeperposition = "bottomleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Left**`}) } if (i.customId === `${key}-topleftkeep`) { status = true; keeperposition = "topleft"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Left**`}) } if (i.customId === `${key}-bottomrightkeep`) { status = true; keeperposition = "bottomright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Right**`}) } if (i.customId === `${key}-toprightkeep`) { status = true; keeperposition = "topright"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Right**`}) } if (i.customId === `${key}-topmiddlekeep`) { status = true; keeperposition = "topmiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Top Middle**`}) } if (i.customId === `${key}-bottommiddlekeep`) { status = true; keeperposition = "bottommiddle"; i.reply({ephemeral: true, content: `:white_check_mark: **Chosen: Bottom Middle**`}) } counter++; z = await gamechannel.send({ components: [], ephemeral: false, content: `<@${gamedatabase[key].user1}>, you have successfully chosen a position!`, }); if (shootingposition === keeperposition) { ender++ g = await gamechannel.send({ content: `<@${gamedatabase[key].user2}> aligned the ball and shoots to the **${shootingposition}**!\n<@${gamedatabase[key].user1}> dives to the **${keeperposition}**!\n\n<@${gamedatabase[key].user1}> saves the goal!\nCurrent Score: **<@${gamedatabase[key].user1}>-<@${gamedatabase[key].user2}> : ${gamedatabase[key].user1points}-${gamedatabase[key].user2points}**\nhttps://cdn.discordapp.com/attachments/1026610112175017987/1039709526225596516/Assets_Save_v1.gif`, }); } else { ender++ boolhit2 = true gamedatabase[key].user2points++; fs.writeFileSync( "./gamedatabase.json", JSON.stringify(gamedatabase), (err) => { if (err) console.log(err); } ); g= await gamechannel.send({ content: `<@${gamedatabase[key].user2}> aligned the ball and shoots to the **${shootingposition}**!\n<@${gamedatabase[key].user1}> dives to the **${keeperposition}**!\n\n<@${gamedatabase[key].user2}> scores the goal!\nCurrent Score: **<@${gamedatabase[key].user1}>-<@${gamedatabase[key].user2}> : ${gamedatabase[key].user1points}-${gamedatabase[key].user2points}**`, }); g = await gamechannel.send({content: `https://cdn.discordapp.com/attachments/1028084538020200468/1042927320144552016/Asset_Goal_v1_2.gif`}) } } } if(gamedatabase[key] .user1points > gamedatabase[key] .user2points || gamedatabase[key] .user1points < gamedatabase[key] .user2points && counter % 2 == 0){ done = true; } }