InteractionCollector
classe · Source
Collects interactions. Will automatically stop if the message (messageDelete or messageDeleteBulk), channel (channelDelete), or guild (guildDelete) is deleted. Interaction collectors that do not specify time or idle may be prone to always running. Ensure your interaction collectors end via either of these options or manual cancellation.
Extends: Collector
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
client | Client | The client on which to collect interactions |
options? | InteractionCollectorOptions | The options to apply to this collector Default: {}. |
Properties
messageId
The message from which to collect interactions, if provided Source
channelId
The channel from which to collect interactions, if provided Source
guildId
The guild from which to collect interactions, if provided Source
interactionType
The type of interaction to collect Source
componentType
The type of component to collect Source
users
The users that have interacted with this collector Source
total
The total number of interactions collected Source
endReason
The reason this collector has ended with, or null if it hasn't ended yet Source
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
Methods
collect
Handles an incoming interaction for possible collection. Parameters
| Name | Type | Description |
|---|---|---|
interaction | Interaction | The interaction to possibly collect |
Returns: SnowflakeSource
dispose
Handles an interaction for possible disposal. Parameters
| Name | Type | Description |
|---|---|---|
interaction | Interaction | The interaction that could be disposed of |
Returns: SnowflakeSource
empty
Empties this interaction collector. Source
_handleMessageDeletion
Handles checking if the message has been deleted, and if so, stops the collector with the reason 'messageDelete'. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message that was deleted |
Returns: voidSource
_handleChannelDeletion
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
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
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
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
Events
collect
Emitted whenever an interaction is collected. Parameters
| Name | Type | Description |
|---|---|---|
interaction | Interaction | The interaction that was collected |
| Source |
dispose
Emitted whenever an interaction is disposed of. Parameters
| Name | Type | Description |
|---|---|---|
interaction | Interaction | The interaction 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 |