Skip to content
This repository was archived by the owner on Mar 8, 2025. It is now read-only.

Latest commit

 

History

History
29 lines (24 loc) · 711 Bytes

File metadata and controls

29 lines (24 loc) · 711 Bytes

TypicalBot Events

Minimalistic event library for Discord.js.

Handling Events

import { EventHandler } from '@typicalbot/events';

// Add events to a collection
const events = new Collection<keyof ClientEvents, EventHandler<any>[]>();

// Register events in client logic
events.forEach((value, key) => {
    if (key === 'ready') {
        client.once(key, (...args) => {
            for (const handler of value) {
                handler(client, ...args);
            }
        });
    } else {
        client.on(key, (...args) => {
            for (const handler of value) {
                handler(client, ...args);
            }
        });
    }
})