I am coding a discord bot in javascript. I have a JSON file for warnings specific users have. the format is like this:
{
"userOne": {
"one": "spamming"
"two": "sexism"
}
"userTwo": {
"one": "spamming"
}
}
I need to be able to get information on a specific user. I know the name of the user, but am unable to get the information on them. I am currently using this code:
for (nick in warnings) {
if (nick == user) {
userWarnings=warnings.nick
console.log(userWarnings);
}
}
warnings is the name of the file that has been parsed. user is the name of the user I want to find the warnings for (Eg: userTwo).
when I run the code, the value of userWarnings is undefined. I know why this is, I just don't know how to fix it.
conclusion: is there a way to find the information on a user if I know their name.