MessageCollector
classe · Source
Collects messages on a channel. Will automatically stop if the channel (channelDelete), thread (threadDelete), or guild (guildDelete) is deleted.
Extends: Collector
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
channel | TextBasedChannels | The channel |
options | MessageCollectorOptions | The options to be applied to this collector |
Properties
channel
The channel Source
received
Total number of messages that were received in the channel during message collection Source
endReason
readonly · nullable
The reason this collector has ended with, or null if it hasn't ended yet Source
client
readonly
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
nullable · private
Timeout for cleanup Source
_idletimeout
nullable · private
Timeout for cleanup due to inactivity Source
next
readonly
Returns a promise that resolves with the next collected element; rejects with collected elements if the collector finishes without receiving a next element Source
Methods
collect
private
Handles a message for possible collection. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message that could be collected |
Returns: SnowflakeSource
dispose
Handles a message for possible disposal. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message that could be disposed of |
Returns: SnowflakeSource
_handleChannelDeletion
private
Handles checking if the channel has been deleted, and if so, stops the collector with the reason 'channelDelete'. Parameters
| Name | Type | Description |
|---|---|---|
channel | GuildChannel | The channel that was deleted |
Returns: voidSource
_handleThreadDeletion
private
Handles checking if the thread has been deleted, and if so, stops the collector with the reason 'threadDelete'. Parameters
| Name | Type | Description |
|---|---|---|
thread | ThreadChannel | The thread that was deleted |
Returns: voidSource
_handleGuildDeletion
private
Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'. Parameters
| Name | Type | Description |
|---|---|---|
guild | Guild | The guild that was deleted |
Returns: voidSource
handleCollect
async
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
async
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
Events
collect
Emitted whenever a message is collected. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message that was collected |
| Source |
dispose
Emitted whenever a message is disposed of. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message that was disposed of |
| 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 |