feat: descrete wargaming response

This commit is contained in:
TresAbhi committed 2023-04-27 00:21:39 +00:00
1 parent fd1dc40918
commit d4f676091d
14 files changed
+211 -297

No files matched your search

+10 -7
View File
@@ -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;
}