I have a problem with discord.js v12 when trying to run the bot

im running a discord.js v12 bot and when i try to run it this error pops up

      client.user.setActivity(newActivity);
                  ^

TypeError: Cannot read properties of null (reading 'setActivity')
    at Timeout._onTimeout (C:\Users\Alexu\Desktop\cookie checker\events\ready.js:19:19)
    at listOnTimeout (node:internal/timers:568:17)
    at processTimers (node:internal/timers:510:7)

Solution 1:

This means the client is not ready at the time. Put this in the ready event

client.once("ready", () => {
  client.user.setActivity(newActivity)
}