'client.user' is possible null

The error that VS Code gives me is in the title.

const client: Client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildPresences,
  ],
});

function setActivity() {
  client.user.setPresence({
    activities: [
      {
        name: "SOME TEXT",
        type: ActivityType.Playing,
      },
    ],
    status: "online",
  });
}

Can someone help me?

I'm a newbie in TypeScript btw.

discord.js@14.8.0
nodejs v18.15.0
Was this page helpful?