Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
DiscordJS No se pueden leer las propiedades de nulo (leyendo 'id')

Estoy intentando iniciar sesión cuando alguien se une a vc y mueve vc, el registro de vc en movimiento funciona bien, pero cuando se une a vc da el error TypeError: Cannot read properties of null (reading 'id')

 module.exports = async (client, oldState, newState) => { if (oldState.channel && newState.channel && oldState.channel.id !== newState.channel.id) { const embed = new Discord.MessageEmbed() .setAuthor({ name: newState.member.user.tag, iconURL: newState.member.user.displayAvatarURL({ dynamic: true }) }) .setTimestamp() .setColor(config.colour) .setFooter({ text: newState.guild.name, iconURL: newState.guild.iconURL({ dynamic: true }) }) .setDescription(`**${newState.member} moved from \`${oldState.channel.name}\` to \`${newState.channel.name}\`**`) return logChannel.send({ embeds: [embed] }) } if (!oldState.channel.id && newState.channel.id) { const embed = new Discord.MessageEmbed() .setAuthor({ name: newState.member.user.tag, iconURL: newState.member.user.displayAvatarURL({ dynamic: true }) }) .setTimestamp() .setColor(config.colour) .setFooter({ text: newState.guild.name, iconURL: newState.guild.iconURL({ dynamic: true }) }) .setDescription(`**🔊 ${newState.member} has joined \`${newState.channel.name}\` channel.**`) return logChannel.send({ embeds: [embed] }) } } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Cuando se une al canal por primera vez, no hay oldState.channel, por lo que el bot no puede obtener la identificación de un canal que no existe. Puede editar sus declaraciones como;

 if (oldState.channel && newState.channel && oldState.channel.id !== newState.channel.id)

a

 if(oldState.channel && newState.channel){ if(oldState.channel.id != newState.channel.id){ // rest of code } }

tal vez puedas hacer más limpio, pero así es como funciona.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!