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

91
Views
Using message.channel.send in uncaughtException event

I want the uncaughtException and unhandledRejection events to log errors and send the error message in the same channel where the command was executed

function:

function ErrorLog(errortext, message) {
    const ErrorEmbed = new MessageEmbed()
        .setColor(`#${config["color"].error}`)
        .setDescription(`${errortext}`)
    message.channel.send({ embeds: [ErrorEmbed] })
    return
}

event:

process.on("unhandledRejection", ({ err, message }) => {
    ErrorLog(`An unknown and unexpected error has occurred! \`\`\`${err}\`\`\``, message)
    console.log(`An unknown and unexpected error has occurred! ${err}`);
    process.exit(1);
});

However, it gives me an error saying Cannot read properties of undefined (reading 'send'), and I'm not exactly sure how to fix this.

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

0

Just simply use try catch

try{
//your code
    }catch(error){
        console.log(error)
        message.channel.send({content: 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!