feat: better error handling

This commit is contained in:
TresAbhi committed 2023-04-26 23:42:15 +00:00
1 parent c494331470
commit 48241bd0d4
12 files changed
+347 -106

No files matched your search

+6 -10
View File
@@ -1,5 +1,5 @@
import { Client, GatewayIntentBits } from 'discord.js';
import cleanup, { EXIT_EVENT_NAMES } from './behaviors/cleanup.js';
import { registerErrorHandlers } from './behaviors/error.js';
import guildMemberAdd from './behaviors/guildMemberAdd.js';
import interactionCreate from './behaviors/interactionCreate.js';
import ready from './behaviors/ready.js';
@@ -13,12 +13,8 @@ const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
});
client.on('error', console.error);
client.on('ready', ready);
client.on('guildMemberAdd', guildMemberAdd);
client.on('interactionCreate', interactionCreate);
client.login(process.env.DISCORD_TOKEN);
EXIT_EVENT_NAMES.forEach((exitEventName) =>
process.on(exitEventName, () => cleanup(client)),
);
registerErrorHandlers(client)
.on('ready', ready)
.on('guildMemberAdd', guildMemberAdd)
.on('interactionCreate', interactionCreate)
.login(process.env.DISCORD_TOKEN);