ListenerUtil

Contains static decorator methods for declaring class methods (within a class extending EventEmitter) as listeners for events that will be emitted by the class or parent classes

Note: This is a TypeScript feature. Javascript users are limited to creating listeners the old fashioned <EventEmitter>on/once(...) way

Source:

Methods

(static) .on(event: string, args: any[]) → MethodDecorator

Declares the decorated method as an event handler for the specified event. Must be registered by calling ListenerUtil.registerListeners()

Note: registerListeners() is already called in the YAMDBF Client constructor and does not need to be called in classes extending it

Parameters:
Name Type Attributes Description
event
string

The name of the event to handle

args
any[]
<repeatable>

Additional static values to pass to the method. Will be passed after any args passed by the event

Source:
Returns:
MethodDecorator

(static) .once(event: string, args: any[]) → MethodDecorator

Declares the decorated method as a single-use event handler for the specified event. Must be registered by calling ListenerUtil.registerListeners()

Note: registerListeners() is already called in the YAMDBF Client constructor and does not need to be called in classes extending it

Parameters:
Name Type Attributes Description
event
string

The name of the event to handle

args
any[]
<repeatable>

Additional static values to pass to the method. Will be passed after any args passed by the event

Source:
Returns:
MethodDecorator

(static) .registerListeners(emitter: EventEmitter, listenerSource?: object) → void

Attaches any listeners registered via the on or once decorators. Must be called after super(), and only in classes extending EventEmitter (which includes the Discord.js Client class and thus the YAMDBF Client class)

If the listenerSource parameter is provided, the object passed will be used as the source of methods to link with events from the given EventEmitter

Parameters:
Name Type Attributes Description
emitter
EventEmitter

EventEmitter to register listeners for

listenerSource
object
<optional>

Object with registered methods to link events to

Source:
Returns:
void