Centralize Handler
Now, we have to create a entralized function, to export and import our events, this makes a better and easier way to export events.
Project Structure
Add an eventIndex.ts
file inside the event
folder.
- eventIndex.ts
Add eventIndex.ts
This is our centralize
handler code:
src/events/eventIndex.ts
import { registerReadyEvent } from './client/ready'
import { eventHandlerInteraction } from './client/interactionCreate'
import { eventHandlerMessage } from './client/messageCreate'
import { ExtendedClient } from '../interfaces/ExtendedClient'
export function eventHandlers(client: ExtendedClient) {
registerReadyEvent(client)
eventHandlerInteraction(client)
eventHandlerMessage(client)
}
💡
You can add more functions like this to centralize event handling.
Verification
Ensure you have imported everything correctly.
Alright, lets move ahead,