• A powerful Typescript decorator function, enabling simple, modular listeners to be built into classes.

    ⚠️ Requires Typescript 5 or greater.

    Parameters

    Returns ((originalMethod, context) => any)

      • (originalMethod, context): any
      • Parameters

        • originalMethod: any
        • context: ClassMethodDecoratorContext<unknown, ((this, ...args) => any)>

        Returns any

    Example

    // Note: DO NOT DIRECTLY COPY THIS EXAMPLE -
    // it uses fake @ symbols due to jsdoc limitations.

    // Reacts with 👍 on the third message received
    class MessageApprover {
    private messageCount: number = 0;

    listener("messageCreate")
    onMessage(message: Message) {
    this.messageCount++;
    if (this.messageCount == 3) message.react("👍");
    }
    }

Generated using TypeDoc