npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord.js-anticrash

v4.0.3-devbuild

Published

Advanced, customizable, and user-friendly error-handling enhancements for Discord bots using discord.js.

Downloads

100

Readme

discord.js-anticrash: ⚡ Powerful Error Handling for Discord.js

Presenting discord.js-anticrash, a powerful npm package 📦 tailored to enhance error handling ⚠️ and logging capabilities 📝 in your Discord.js bots. Seamlessly integrate this package to fortify your bot's stability and streamline the troubleshooting process.

Features 🚀

  • 🔒 Secure: Safeguard your bot from unexpected crashes with proactive error identification and handling.
  • 🔔 Notifications: Receive instant notifications through Discord webhooks whenever errors occur.
  • 🛠 Customizable: Tailor the package to fit your needs by customizing webhook URLs, embed colors, titles, and usernames.
  • 🖥 Console Logging: Enjoy the best-in-class console error logging feature for easy debugging.
  • 🚨 Error Detection: Detects all errors and notifies the developer for comprehensive error tracking.
  • 💪 Strong Error Handling: Employs a robust inbuilt error handling mechanism for enhanced bot stability.
  • 🔄 Regular Updates: Benefit from daily updates to ensure compatibility and incorporate the latest features and improvements.

Installation 📦

Get started by installing discord.js-anticrash using npm:

npm install discord.js-anticrash

Usage 🤖

To implement discord.js-anticrash, import the package and invoke the errorHandling function, providing your Discord.js client and configuration options:

const { Client, GatewayIntentBits, Events } = require("discord.js");
const errorHandling = require("discord.js-anticrash");

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

const config = {
  webhookUrl: "https://discord.com/api/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN",
  embedColor: "#ff0000", // Optional
  embedTitle: "Error", // Optional
  embedAvatarUrl: "https://cdn.discordapp.com/avatars/example", // Optional
  webhookUsername: "Error", // Optional
};

errorHandling(client, config);

client.login("BotToken"); // Your Discord Bot token goes here.

Configuration ⚙️

Customize the behavior of discord.js-anticrash with the config object:

  • webhookUrl (required): The URL of the Discord webhook to send error messages.
  • embedColor (optional): The color of the embed message (default: #ff0000).
  • embedTitle (optional): The title of the embed message (default: Error).
  • embedTitle (optional): The title of the embed message (default: Error).
  • embedAvatarUrl (optional): The title of the embed message (default: None).
  • webhookUsername (optional): The username for the webhook (default: Error).

Error Handling 🚨

discord.js-anticrash delivers advanced error handling for Discord.js:

  • unhandledRejection: Handles unhandled rejections, sending detailed error messages to the Discord webhook.
  • uncaughtException: Manages uncaught exceptions, dispatching detailed error messages to the Discord webhook.
  • uncaughtExceptionMonitor: Monitors uncaught exceptions and sends detailed error messages to the Discord webhook.
  • warning: Deals with warnings, forwarding detailed warning messages to the Discord webhook.
  • exit: Manages bot exit events, sending detailed exit messages to the Discord webhook.

Example 🌐

Witness discord.js-anticrash in action, handling errors and uncaught exceptions:

const { Client, GatewayIntentBits, Events } = require("discord.js");
const errorHandling = require("discord.js-anticrash");

const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
});

const config = {
  webhookUrl: "https://discord.com/api/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN", // REQUIRED
  embedColor: "#ff0000", // Optional
  embedTitle: "Error", // Optional
  webhookUsername: "Error", // Optional
};

errorHandling(client, config);

client.on(Events.MessageCreate, (message) => {
  if (message.content === "!crash") {
    throw new Error("Simulated crash!"); // Example test.
  }
});

client.login("BotToken"); // Your Discord Bot token goes here.

License 📜

discord.js-anticrash is licensed under the Apache License 2.0. This license allows you to use, modify, and distribute the package under certain conditions. Please review the LICENSE file for the full text of the Apache License 2.0. By using or contributing to this project, you agree to abide by the terms specified in the license.

Conclusion 🎉

discord.js-anticrash is your go-to solution for Discord.js bot development, ensuring security, reliability, and ease of maintenance. With advanced error handling, customizable configurations, and detailed error messages, discord.js-anticrash elevates your Discord.js error handling experience.