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] }) } } }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.