ReactionCollector
classe · Source
Collects reactions on messages. Will automatically stop if the message (messageDelete or messageDeleteBulk), channel (channelDelete), thread (threadDelete), or guild (guildDelete) is deleted.
Extends: Collector
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message upon which to collect reactions |
options? | ReactionCollectorOptions | The options to apply to this collector Default: {}. |
Properties
message
The message upon which to collect reactions Source
users
The users that have reacted to this message Source
total
The total number of reactions 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 reaction for possible collection. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The reaction to possibly collect |
user | User | The user that added the reaction |
Returns: Snowflake \| stringSource
dispose
Handles a reaction deletion for possible disposal. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The reaction to possibly dispose of |
user | User | The user that removed the reaction |
Returns: Snowflake \| stringSource
empty
Empties this reaction 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
key
Gets the collector key for a reaction. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The message reaction to get the key for |
Returns: SnowflakestringSource
Events
create
Emitted whenever a reaction is newly created on a message. Will emit only when a new reaction is added to the message, as opposed to Collector#collect which will be emitted even when a reaction has already been added to the message. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The reaction that was added |
user | User | The user that added the reaction |
| Source |
collect
Emitted whenever a reaction is collected. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The reaction that was collected |
user | User | The user that added the reaction |
| Source |
dispose
Emitted when the reaction had all the users removed and the dispose option is set to true. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The reaction that was disposed of |
user | User | The user that removed the reaction |
| Source |
remove
Emitted when the reaction had one user removed and the dispose option is set to true. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The reaction that was removed |
user | User | The user that removed the reaction |
| 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 |