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

145
Views
My bot can't take errors when failling to run a "join" voice channel command

I'm currently coding a discord.js bot and I made this join command so the bot can join my voice channel

module.exports.run = async (client, message, args) => {

let membervc = message.member.voice.channel;
let botvc = message.guild.me.voice.channel;
if(!membervc) return message.send('You need to join a voice channel first.');
if(botvc){
    if(!(botvc.members.size - 1)) return message.reply(`I am already on ${botvc}`);
    if(membervc.id == botvc.id) return message.reply('We are already on the same voice channel.');
};
membervc.join();
}

The problem is that I have no idea how to make it so that if the last function gets an error or doesn't work at all It can send an error message to the user like @User, I could not join the channel, "THE ERROR" :/ I don't want my bot to crash and having to run it again just because of one small detail. Is there a way to fix it? It would help me a lot! Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I would not let the user know about the error, because it might just confuse them, but you can do try catch to check if it goes through and if not message is sent.

try {
      membervc.join();
} catch(error){
      console.log(error);
      message.reply(`Something went wrong while joining voice channel`);
}
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!