TypeError: Canot Read property `get` of undefinded

Hi i have error TypeError: Canot Read property get of undefinded

My code with error:

  let channel = client.channels.cache.get(CHANNEL) || await client.channels.fetch(CHANNEL)
  if(!channel) return;

  const connection = await channel.join()
  connection.play(ytdl(LIVE))
}
}, 20000)

client.login(TOKEN);```


Someone help?

Your code is attempting to access the client.channels.cache prior to your having logged in.

This may not be true, we are not shown the entire function this code is inside of, it seems to be some setTimeout/Interval?

I can accept that… the cache property is likely null at that moment.