I've already tried a lot of stuff and IDK what to do anymore.
The idea is to get the object key, from the discord value and then return it.
But it refuses to work, I've already tried other ways and got the same result.
Example users value:
"45556874": {
"discord": [
"592881581857701908"
],
"debugger": true,
"blacklisted": false,
"games": []
},
"101426233": {
"discord": [
"592881581857701908"
],
"debugger": true,
"blacklisted": false,
"games": []
},
"2589755903": {
"discord": [
"592881581857701908"
],
"debugger": true,
"blacklisted": false,
"games": []
},
"2804506785": {
"discord": [
"900280562781138944"
],
"debugger": false,
"blacklisted": false,
"games": []
}
Function:
async function getRoblox(Id){
const users = await db.get("users");
let RoId = null;
for (const entry of Object.entries(users)) {
const [roId, value] = entry;
if(Array.isArray(value.discord)){
for (const DisId of value.discord) {
if (DisId === Id) {
RoId = roId;
}
}}
};
return RoId;
}