diff --git a/index.js b/index.js index dfd8e0d..aba9467 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,7 @@ const app = express(); global.log = log; const Discord = require("discord.js") -const client = new Discord.Client({intents: ["Guilds", "DirectMessages", "MessageContent", "GuildMembers"]}) +const client = new Discord.Client({ intents: ["Guilds", "DirectMessages", "MessageContent", "GuildMembers"] }) const pool = MariaDB.createPool({ host: process.env.DB_HOST, @@ -96,6 +96,16 @@ client.on("messageCreate", async (message) => { global.dmHandlers[message.author.id](message); }); +// Global error handling for unhandled promise rejections and uncaught exceptions +process.on('unhandledRejection', (reason, promise) => { + log.error('Unhandled Rejection at:', promise, 'reason:', reason); + // Application specific logging, throwing an error, or other logic here +}); + +process.on('uncaughtException', (error) => { + log.error('Uncaught Exception thrown:', error); + // Application specific logging, throwing an error, or other logic here +}); const port = process.env.SERVER_PORT || 3000;