Help with the discord bot please!

My discord is not allowing me to turn it on.

I checked versions, everything, but it is broken, again, again, and again…

Error:

intents: [Intents. FLAGS. GUILDS, Intents. FLAGS. GUILD_MEMBERS]

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

Versions:
Node js - 18.12.1
Discord.js - 14.8

Can you help please?

Code:

const Discord = require('discord.js');
const { Intents } = require('discord.js');

const client = new Discord.Client({
    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS]
});

const prefix = "!";

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`);
    welcomeChannel = client.channels.cache.get('#######');
});

// Joining Code \\
client.on('guildMemberAdd', member => {
    const embed = new Discord.MessageEmbed()
        .setColor('#00ff00')
        .setTitle('Welcome to the server! 🎉')
        .setDescription(`Welcome to the official discord server, ${member}!`)
        .setThumbnail(member.user.displayAvatarURL())
        .setTimestamp();
    welcomeChannel.send(embed); // Send the welcome message in the welcome channel
});

// Bot Login Token \\
client.login('#####');

Your code is made for v13. See

And store your token using secrets. Regenerate it through the ‘Bot’ section of your app in Discord Developer Portal

2 Likes
import { Client, GatewayIntentBits, ActionRowBuilder, ButtonBuilder, } from 'discord.js';

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

some example of how to change things.

const TOKEN = process.env.BOT_TOKEN;

and this is example of using dotenv