mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: descrete wargaming response
This commit is contained in:
1 parent
fd1dc40918
commit
d4f676091d
14 files changed
+211
-297
No files matched your search
+10
-7
@@ -1,6 +1,7 @@
|
||||
import { Client, EmbedBuilder, TextChannel } from 'discord.js';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
||||
import isDev from '../utilities/isDev.js';
|
||||
|
||||
export const PROCESS_ERROR_EVENTS = ['uncaughtException'];
|
||||
export const CLIENT_ERROR_EVENTS = ['error'];
|
||||
@@ -18,19 +19,21 @@ function handleError(error: Error, client: Client) {
|
||||
.setTitle('Skilled Bot ran into a catastrophic error')
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setDescription(
|
||||
`Total shutdown was avoided! Error:\n\n\`\`\`${error.name}\n${error.message}\n${error.stack}\n${error.cause}\`\`\``,
|
||||
`\`\`\`${error.name}\n${error.message}\n${error.stack}\n${error.cause}\`\`\``,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
export function registerErrorHandlers(client: Client) {
|
||||
PROCESS_ERROR_EVENTS.forEach((name) =>
|
||||
process.on(name, (error) => handleError(error, client)),
|
||||
);
|
||||
CLIENT_ERROR_EVENTS.forEach((name) =>
|
||||
client.on(name, (error) => handleError(error, client)),
|
||||
);
|
||||
if (!isDev()) {
|
||||
PROCESS_ERROR_EVENTS.forEach((name) =>
|
||||
process.on(name, (error) => handleError(error, client)),
|
||||
);
|
||||
CLIENT_ERROR_EVENTS.forEach((name) =>
|
||||
client.on(name, (error) => handleError(error, client)),
|
||||
);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
Reference in new issue
Block a user