Partial refactoring/bug fix w/ session time correction
This commit is contained in:
6 files changed
+141
-143
No files matched your search
@@ -4,15 +4,14 @@ const { GatewayIntentBits } = require('discord.js');
|
||||
|
||||
const path = require("path");
|
||||
const fs = require('fs');
|
||||
|
||||
let client = new DayzR({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers] }, config);
|
||||
client.build()
|
||||
const { HandleActivePlayersList } = require('./util/LogsHandler');
|
||||
|
||||
// Log all uncaught exceptions before killing process.
|
||||
process.on('uncaughtException', async (error) => {
|
||||
let d = new Date();
|
||||
// Asynchronously write the error message to a log file using Promises
|
||||
await new Promise((resolve, reject) => {
|
||||
if (HandleActivePlayersList.lastSendMessage) HandleActivePlayersList.lastSendMessage.delete().catch(error => client.sendError(channel, `HandleActivePlayersList Error: \n${error}`)); // Remove previous embed message before closing
|
||||
fs.appendFile(path.join(__dirname, "./logs/Logs.log"),
|
||||
`{"level":"error","message":"${d.getHours()}:${d.getMinutes()} - ${d.getMonth()+1}:${d.getDate()}:${d.getFullYear()} | uncaughtException: ${error.stack}"}`, (logErr) => {
|
||||
if (logErr) {
|
||||
@@ -25,6 +24,9 @@ process.on('uncaughtException', async (error) => {
|
||||
});
|
||||
});
|
||||
|
||||
// Now, you can re-throw the error
|
||||
// Now gracefully close the program
|
||||
process.exit()
|
||||
});
|
||||
|
||||
let client = new DayzR({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers] }, config);
|
||||
client.build()
|
||||
Reference in new issue
Block a user