Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

245
Vistas
Discord js v13 setChannel is undefined

I'm started to learn discord.js library and trying to make event when user joins special voice channel and bot creates a new one and moves user. Now bot can create channel, but when it tries to move user it have an error "Cannot read properties of undefined (reading 'setChannel')"

Here is my code:

const {Collection} = require('discord.js')
let privateVoice = new Collection()
config = require('../config.json');

module.exports = async (bot, oldState, newState)=>{
  const user = await bot.users.fetch(newState.id)
  const member = newState.guild.members.fetch(user)
  if(!oldState.channel && newState.channel.id === (config.createChannel)){
    const channel = await newState.guild.channels.create(user.tag,{
      type: "GUILD_VOICE",
      parent: newState.channel.parent
    })
      member.voice.setChannel(channel);
      privateVoice.set(user.id, channel.id)
  }
    };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are trying to fetch a member by their user object and you aren't even awaiting it. .fetch is a Promise and you use their ID, not their user object.

Instead of using this to get their member object:

const member = newState.guild.members.fetch(user)

Use VoiceState.member

const { member } = newState //object destructuring for cleaner syntax. 'const member = newState.member' is also fine

But this can be null since it gets them from the member cache (see here). If you really want to fetch them, make sure to await it and use their ID

const member = await newState.guild.members.fetch(user.id)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda