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

235
Views
How do I disconnect a user from a discord channel with discord js?

The main issue seems to be that things are undefined. For example, a very simple version of something I have tried:

else if (message.content.startsWith("!dc")) {
    message.author.voice.setChannel(null);
}

Resulting in the terminal returning:

TypeError: Cannot read properties of undefined (reading 'setChannel')

I'm not quite sure how to "define" these as some solutions I've found online seem to do what I am trying to do in a similar way. Am I just missing something obvious?

I also have these Intents declared at the top.

const client = new Discord.Client({
intents: [
    Discord.Intents.FLAGS.GUILDS,
    Discord.Intents.FLAGS.GUILD_MESSAGES,
    Discord.Intents.FLAGS.GUILD_VOICE_STATES,
    Discord.Intents.FLAGS.GUILD_MEMBERS
    ]
});
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

As @Bee said in the comments to my question:

it'd be msg.member

about 4 years ago · Juan Pablo Isaza Report

0

I don't think you can disconnect yourself while you are admin. So try this

return <member>.voice.setChannel(null)
    .then(() => message.channel.send(`Done`))
    .catch((err) => message.channel.send(`\\❌ | ${err}!`));
about 4 years ago · Juan Pablo Isaza Report

0

Try this code:

message.member.voice.disconnect()
    .catch(console.error);
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!