Class: MessageCollector
Collects messages on a channel.
Extends
Constructors
Constructor
new MessageCollector(
channel,options?):MessageCollector
Parameters
| Parameter | Type |
|---|---|
channel | BaseChannel |
options | MessageCollectorOptions |
Returns
MessageCollector
Overrides
Properties
channel
channel:
BaseChannel
channelId
channelId:
string
client
readonlyclient:Client
Inherited from
collected
collected:
Collection<string,Message>
Inherited from
ended
ended:
boolean=false
Inherited from
filter
filter: (
item, ...args) =>boolean
Parameters
| Parameter | Type |
|---|---|
item | Message |
...args | any[] |
Returns
boolean
Inherited from
options
options:
CollectorOptions<Message>
Inherited from
processed
processed:
number=0
total
total:
number=0
Methods
[asyncIterator]()
[asyncIterator]():
AsyncIterableIterator<[string,Message]>
Allows iterating over collected items asynchronously.
Returns
AsyncIterableIterator<[string, Message]>
Example
for await (const [id, message] of collector) {
console.log(`Received message: ${message.content}`);
}
Inherited from
checkEnd()
checkEnd():
void
Check if we should end upon collecting/disposing
Returns
void
Inherited from
collect()
collect(
message):string|null
Returns a key if the item should be collected, or null to skip
Parameters
| Parameter | Type |
|---|---|
message | Message |
Returns
string | null
Overrides
dispose()
dispose(
message):string|null
Returns a key if the item should be disposed, or null to skip
Parameters
| Parameter | Type |
|---|---|
message | Message | { channelId: string; id: string; } |
Returns
string | null
Overrides
endReason()
endReason():
string|null
Check if there's a reason to end
Returns
string | null
Overrides
handleCollect()
handleCollect(
message):void
Evaluates an item and possibly passes it to the collector
Parameters
| Parameter | Type |
|---|---|
message | Message |
Returns
void
Overrides
handleDispose()
handleDispose(
item, ...args):void
Evaluates an item and possibly removes it from the collector
Parameters
| Parameter | Type |
|---|---|
item | Message |
...args | any[] |
Returns
void
Inherited from
stop()
stop(
reason?):void
Stops the collector.
Parameters
| Parameter | Type | Default value |
|---|---|---|
reason | string | "user" |
Returns
void