How to handle HTTP errors?

https://discordjs.guide/popular-topics/errors
I've read this and still don't know how to properly handle HTTP errors.

I don't really know how to handle a 403 (FORBIDDEN) error for example.
How can I do this?

Update: Can I just do this?
import { DiscordAPIError, RESTJSONErrorCodes } from "discord.js";

try {
} catch (err) {
  // Handle HTTP errors
  if (err instanceof DiscordAPIError) {
    // Handle here
  }

  // JSON error codes
  if (err.code === RESTJSONErrorCodes.Unauthorized) {
    // Handle here
  }
}
Imagine a guide... that explores the many possibilities for your discord.js bot.
Was this page helpful?