Discordjs could not catch a DiscordAPIError
Solution 1:
try/catch should be used in combination with async/await. If you want to use synchronous then/catch, use the respective .catch()
callback.
client.users.fetch('does-not-exist')
.then(function (user) {
user.send('hello');
})
.catch(err => /* error handle */);
If you want to ignore the error void it
.catch(_ => null);
How it would look with async await
try {
const user = await client.users.fetch('does-not-exist')
} catch (err) {
/* Handle Error */
}