more crash protection
This commit is contained in:
19
index.js
19
index.js
@@ -57,4 +57,23 @@ client.on(Events.GuildMemberAdd, async (member) => {
|
||||
});
|
||||
|
||||
// Log in
|
||||
// Catch library/client errors to prevent unhandled 'error' events from crashing the process
|
||||
client.on('error', (err) => {
|
||||
console.error('Client error:', err);
|
||||
});
|
||||
|
||||
// Some libraries emit shard-specific errors — log them for diagnostics
|
||||
client.on('shardError', (err) => {
|
||||
console.error('Shard error:', err);
|
||||
});
|
||||
|
||||
// Global handlers to capture unexpected problems and provide diagnostics
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error('Uncaught exception:', err);
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
||||
});
|
||||
|
||||
client.login(BOT_TOKEN);
|
||||
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "ecstest1",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ecstest1",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@fluxerjs/core": "^1.2.2",
|
||||
"dotenv": "^17.3.1"
|
||||
|
||||
Reference in New Issue
Block a user