Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda