I have a discord bot and it saves achievements in a JSON file. The JSON structure is like this:
{
"784095768305729566": {
"coins": 14598,
"achievements": {
"taking_inventory": true
}
},
}
The command should give you an overview of what achievements you already have.
I want to create an embed and run a for loop for every sub-thing of achievements. If the value is true, the for loop should take the value name and the value and add a field to the embed where the field title is the value name.
I have multiple problems there.
- I don't know how to get value names and values. I already tried
Object.keys(...)but that gives all keys and not one by one. I don't know how to get the values. - I don't know how to make the for loop as long as all sub-things of
achievements.
I tried:
for(var i = 0; i<datafile[id].achievements.length; i++){...}
but that didn't work wither.