#Promise { <pending> }

17 messages · Page 1 of 1 (latest)

royal rivet
#
    try {
    const rep = await (db.get(id)) ?? 0
     db.set(id, rep+1)
     return (rep+1)
    } catch (error) {
      console.log(error)
    }
    
  }```

This is my code when i call the function 

message.mentions.members?.forEach((mem) => {
const rep = reputation(mem.id)
console.log(rep)
message.channel.send(Gave one reputation to ${mem} (${rep}))
})```

it says Object Promise

mental lintel
mental lintel
# royal rivet Doesnt mskr a different

Hopefully you understand how async/await works and promises. When you make a function that is async it returns a promise no matter what. You don't even await your own async function. I pointed out db.set and db.get because you only awaited db.set so your condition was going to be wrong since you were not awaiting db.get. but you still need to await reputation

royal rivet
#

I see

royal rivet
#

i shld do

#

await reputation()

mental lintel
royal rivet
#

How do i do that in a for loop

mental lintel
#

You are using a forEach. The arrow function should be async

#

.forEach(async (mem) =>

royal rivet
#

Ohhhh

#

i see

royal rivet
mental lintel
royal rivet