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

107
Views
Function still raises exception even with catch statement

Im suffering from a weird issue

basically I have the function

msg.guild.members.unban(userID)

This function returns a promise

I then use a .then statement for further code after the promise has been fulfilled

msg.guild.members.unban(element)
         .then(function() {console.log("worked")})

Anyways this function will in certain cases raise an Exception

Therefore I use the .catch statement to handle it

msg.guild.members.unban(element)
         .catch(console.log("Not banned"))
         .then(function() {})

However this does not seem to work

as a discord api error will still be raised and the program terminated

The error is an DiscordAPIError

Even if I remove the .then statement and just have a catch statement the program is still terminated

msg.guild.members.unban(element)
   .catch()
about 4 years ago · Juan Pablo Isaza
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!