TypeError: Cannot read properties of undefined (reading 'users')
at Object.execute (D:\Mortal\Belgeler\Kod Denemeleri\Discord Botu\Via\v4 (v14)\commands\Kullanıcı\profil.js:34:55)
at module.exports (D:\Mortal\Belgeler\Kod Denemeleri\Discord Botu\Via\v4 (v14)\events\interactionCreate.js:28:21)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
const APIFetch = await interaction.client.api.users(user ? user.id : interaction.user.id).get()
I could not find the solution to the problem on the internet because it is a new version. I researched for about 2 hours; At first, I looked at the sites and then looked at what data I could pull through interaction or the client. We can't pull API data. That's why we get the error "users" can't be read. At least that's it, as I understand it... How do I resolve this error?
Use interaction.client.users directly:
const data = await interaction.client.users.fetch(user ? user.id : interaction.user.id);