1

I want to get each user who has a specific value in their row and access each of them. I want something like

sql.prepare("SELECT * FROM raid WHERE raid1 > 0 AND NOT id='685337576810610734'").get().forEach(async (user) => {
  bot.users.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!")
  let usera = await getScore.get(user)
  usera.raid1 = 0
  setScore.run(usera)
})

But for it to actually go through each user who has raid1 > 0. Im trying to iterate through the array as its output but I have no idea how to start this out. Node.js The code returns a Type not a function error at the .get() I want to have it go through each user who passed the WHERE raid1 > 0 .

The sqlite method doesn't work and Im not sure how to get all users who have raid1 > 0.

king
  • 127
  • 1
  • 7
  • 1
    Welcome to SO! Please be a bit more specific about the requirements, input and expected/actual output. What is wrong with this code? Thanks for clarifying. – ggorlen Apr 17 '20 at 01:25

1 Answers1

1

Since discord.js v12 you now need to access the users collection using cache.

So your solution would be:

sql.prepare("SELECT * FROM raid WHERE raid1 > 0 AND NOT id='685337576810610734'").get().forEach(async (user) => {
  bot.users.cache.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!")
  let usera = await getScore.get(user)
  usera.raid1 = 0
  setScore.run(usera)
})
Syntle
  • 5,168
  • 3
  • 13
  • 34