'Why is Fetch Undefined?

I am copying a code DIRECTLY from discord.js guide to send a direct message to myself (and only myself) through my bot.

module.exports = {
     callback: async(client) => {

        const user = await client.users.fetch('503965897203908609');
        user.send('content');

    }
}

here's the relevant code. and when I run the command, I get

TypeError: Cannot read properties of undefined (reading 'fetch')

WHY



Solution 1:[1]

Because your client.users is undefined, if we try to access a property on undefined it will throw an error.

as to why client.users is undefined, that would be something which requires more code to look at

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Umair Ahmed