Currently, I am facing an issue with my function. Utilizing a MongoDB Database to validate if something exists, the objective is to return false when a data value is true and false otherwise.
Up until this point, everything seems to be functioning correctly. However, the function only returns "undefined". Despite spending over an hour testing various solutions, none have proven successful.
I am hoping that someone could assist me in ensuring the function properly returns true or false.
Note: I even attempted an asynchronous approach without success.
function CheckActiveGamesPlayer1(memberid) {
console.log("3")
db.findOne({ GuildID: guild.id, Player1: memberid }, async(err, data) => {
if (data.Ingame === true) {
console.log("4")
Embed.setDescription(`<@${memberid}> is in an active game. Can't start the game!`).setColor("RANDOM");
channel.send({ embeds: [Embed], ephemeral: true })
return false;
} else {
console.log("5")
return true;
}
})
}