Collector
classe · Source
Abstract class for defining a new Collector.
Extends: EventEmitter
Properties
client
The client that instantiated this Collector Source
filter
The filter applied to this collector Source
options
The options of this collector Source
collected
The items collected by this collector Source
ended
Whether this collector has finished collecting Source
_timeout
Timeout for cleanup Source
_idletimeout
Timeout for cleanup due to inactivity Source
next
Returns a promise that resolves with the next collected element; rejects with collected elements if the collector finishes without receiving a next element Source
endReason
The reason this collector has ended with, or null if it hasn't ended yet Source
Methods
handleCollect
Call this to handle an event as a collectable element. Accepts any event data as parameters. Parameters
| Name | Type | Description |
|---|---|---|
args | * | The arguments emitted by the listener |
Returns: Promise<void>Source
handleDispose
Call this to remove an element from the collection. Accepts any event data as parameters. Parameters
| Name | Type | Description |
|---|---|---|
args | * | The arguments emitted by the listener |
Returns: Promise<void>Source
stop
Stops this collector and emits the end event. Parameters
| Name | Type | Description |
|---|---|---|
reason? | string | The reason this collector is ending Default: 'user'. |
| Source |
resetTimer
Resets the collector's timeout and idle timer. Parameters
| Name | Type | Description |
|---|---|---|
options? | CollectorResetTimerOptions | Options for resetting |
| Source |
checkEnd
Checks whether the collector should end, and if so, ends it. Returns: boolean — Whether the collector ended or not Source
collect
Handles incoming events from the handleCollect function. Returns null if the event should not be collected, or returns an object describing the data that should be stored. Parameters
| Name | Type | Description |
|---|---|---|
args | * | Any args the event listener emits |
Returns: * \| Promise<?*> — Data to insert into collection, if any Source
dispose
Handles incoming events from the handleDispose. Returns null if the event should not be disposed, or returns the key that should be removed. Parameters
| Name | Type | Description |
|---|---|---|
args | * | Any args the event listener emits |
Returns: * — Key to remove from the collection, if any Source
Events
collect
Emitted whenever an element is collected. Parameters
| Name | Type | Description |
|---|---|---|
args | * | The arguments emitted by the listener |
| Source |
dispose
Emitted whenever an element is disposed of. Parameters
| Name | Type | Description |
|---|---|---|
args | * | The arguments emitted by the listener |
| Source |
end
Emitted when the collector is finished collecting. Parameters
| Name | Type | Description |
|---|---|---|
collected | Collection | The elements collected by the collector |
reason | string | The reason the collector ended |
| Source |