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

244
Views
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 answers
Answer question

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 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!