discord.js-anticrash
v4.0.3-devbuild
Published
Advanced, customizable, and user-friendly error-handling enhancements for Discord bots using discord.js.
Downloads
100
Maintainers
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.