Abstract Class: Collector<K, V>
Abstract class for defining a new Collector
Extends
EventEmitter
Extended by
Type Parameters
| Type Parameter |
|---|
K |
V |
Constructors
Constructor
protectednew Collector<K,V>(client,options?):Collector<K,V>
Parameters
| Parameter | Type |
|---|---|
client | Client |
options | CollectorOptions<V> |
Returns
Collector<K, V>
Overrides
EventEmitter.constructor
Properties
client
readonlyclient:Client
collected
collected:
Collection<K,V>
ended
ended:
boolean=false
filter
filter: (
item, ...args) =>boolean
Parameters
| Parameter | Type |
|---|---|
item | V |
...args | any[] |
Returns
boolean
options
options:
CollectorOptions<V>
Methods
[asyncIterator]()
[asyncIterator]():
AsyncIterableIterator<[K,V]>
Allows iterating over collected items asynchronously.
Returns
AsyncIterableIterator<[K, V]>
Example
for await (const [id, message] of collector) {
console.log(`Received message: ${message.content}`);
}
checkEnd()
checkEnd():
void
Check if we should end upon collecting/disposing
Returns
void
collect()
abstractcollect(item, ...args):K|null
Returns a key if the item should be collected, or null to skip
Parameters
| Parameter | Type |
|---|---|
item | V |
...args | any[] |
Returns
K | null
dispose()
abstractdispose(item, ...args):K|null
Returns a key if the item should be disposed, or null to skip
Parameters
| Parameter | Type |
|---|---|
item | V |
...args | any[] |
Returns
K | null
endReason()
endReason():
string|null
Check if there's a reason to end
Returns
string | null
handleCollect()
handleCollect(
item, ...args):void
Evaluates an item and possibly passes it to the collector
Parameters
| Parameter | Type |
|---|---|
item | V |
...args | any[] |
Returns
void
handleDispose()
handleDispose(
item, ...args):void
Evaluates an item and possibly removes it from the collector
Parameters
| Parameter | Type |
|---|---|
item | V |
...args | any[] |
Returns
void
stop()
stop(
reason?):void
Stops the collector.
Parameters
| Parameter | Type | Default value |
|---|---|---|
reason | string | "user" |
Returns
void