[Events] Events become classes with typings. (#19)

This commit is contained in:
2026-09-30 06:48:01 -07:00
committed by GitHub
parent 56f528c0c3
commit 1757ef2f8a
15 changed files with 119 additions and 91 deletions
+2 -3
View File
@@ -1,4 +1,4 @@
import { Client as DiscordClient, GatewayIntentBits, MessageFlags, Partials } from 'discord.js';
import { Client, Client as DiscordClient, GatewayIntentBits, MessageFlags, Partials } from 'discord.js';
import { config } from './config';
import events from './events';
import { Database } from './shared/Database';
@@ -151,7 +151,7 @@ client.on('clientReady', async () => {
events.forEach(event =>
client.on(event.event, (...args) =>
Promise.resolve((event.handler as (...args: unknown[]) => Promise<void>)(...args))
Promise.resolve((event.execute as (context: Client, ...args: unknown[]) => Promise<void>)(client, ...args))
.catch(e => console.error(`Error in ${event.event} handler:`, e))
)
);
@@ -160,7 +160,6 @@ client.on('clientReady', async () => {
console.log('Ready');
});
client.on('error', console.error);
process.on('uncaughtException', console.error);