-2

Error

/home/container/index.js:4

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

TypeError: Cannot read properties of undefined (reading "FLAGS your text")

Code

const { Client, Intents, MessageEmbed } = require('discord.js');

const client = new Client({

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

});

// =============== //

client.on('messageCreate', (message) => {

  if (message.content === 'Hello') {

    message.reply({

      content: `Kısmen Evet`,

      allowedMentions: { repliedUser: true },

    });

  }

});

// =============== //

client.on('guildMemberAdd', (member) => {

  const channel = member.guild.channels.cache.find((ch) => ch.name === 'general');

  if (!channel) return;

  const embed = new MessageEmbed()

    .setColor('#008000')

    .setTitle(`${member.displayName} sunucuya katıldı!`)

    .setDescription(`Hoşgeldin ${member}!`)

    .setThumbnail(member.user.displayAvatarURL())

    .setTimestamp();

  channel.send({ embeds: [embed] });

});

client.on('guildMemberRemove', (member) => {

  const channel = member.guild.channels.cache.find((ch) => ch.name === 'general');

  if (!channel) return;

  const embed = new MessageEmbed()

    .setColor('#FF0000')

    .setTitle(`${member.displayName} sunucudan ayrıldı.`)

    .setDescription(`Güle güle ${member}!`)

    .setThumbnail(member.user.displayAvatarURL())

    .setTimestamp();

  channel.send({ embeds: [embed] });

});

// =============== //

client.on('ready', () => {

  console.log(`Bot başlatıldı: ${client.user.tag}!`);

  client.user.setActivity('your status message', { type: 'WATCHING' })

    .then(presence => console.log(`Activity set to ${presence.activities[0].name}`))

    .catch(console.error);

});

client.login('TOKEN');


I downloaded and tried how many libraries, I asked CHATGPT, the room could not solve it, help me, I'm new :(

Version: Discord v14

Software language: Node.js & Discord.js

I've been struggling with this problem for a long time, I'd be glad if you could help. Solving this issue keeps my motivation a bit more in place.

Rubble
  • 1
  • 1

1 Answers1

0

The solution to your problem I would recommend to use the IntentsBitField instead of Intents: See the discord.js guide for reference: https://discordjs.guide/popular-topics/intents.html#the-intents-bitfield

This means that you need to change your code from this:

const { Client, Intents, MessageEmbed } = require('discord.js');

const client = new Client({

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

});

To This:

const { Client, IntentsBitField, MessageEmbed } = require('discord.js');

const client = new Client({

  intents: [IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMessages],

});

I hope this solves your Issue

Terox
  • 119
  • 1
  • 9
  • This time, my friend, when I say hello to the bot, it does not reply to me. There are no errors in the console, but the bot does not respond to my message when I type Hello – Rubble Apr 02 '23 at 18:36