Skip to content

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

new ReactionCollector(message: Message, options?: ReactionCollectorOptions)

Parameters

NameTypeDescription
messageMessageThe message upon which to collect reactions
options?ReactionCollectorOptionsThe options to apply to this collector Default: {}.

Properties

message

message: Message

The message upon which to collect reactions Source

users

users: Collection

The users that have reacted to this message Source

total

total: number

The total number of reactions collected Source

endReason

readonly · nullable

endReason: string

The reason this collector has ended with, or null if it hasn't ended yet Source

client

readonly

client: Client

The client that instantiated this Collector Source

filter

filter: CollectorFilter

The filter applied to this collector Source

options

options: CollectorOptions

The options of this collector Source

collected

collected: Collection

The items collected by this collector Source

ended

ended: boolean

Whether this collector has finished collecting Source

_timeout

nullable · private

_timeout: Timeout

Timeout for cleanup Source

_idletimeout

nullable · private

_idletimeout: Timeout

Timeout for cleanup due to inactivity Source

next

readonly

next: Promise

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

collect(reaction: MessageReaction, user: User): Snowflake | string

Handles an incoming reaction for possible collection. Parameters

NameTypeDescription
reactionMessageReactionThe reaction to possibly collect
userUserThe user that added the reaction

Returns: Snowflake \| stringSource

dispose

dispose(reaction: MessageReaction, user: User): Snowflake | string

Handles a reaction deletion for possible disposal. Parameters

NameTypeDescription
reactionMessageReactionThe reaction to possibly dispose of
userUserThe user that removed the reaction

Returns: Snowflake \| stringSource

empty

empty()

Empties this reaction collector. Source

_handleMessageDeletion

private

_handleMessageDeletion(message: Message): void

Handles checking if the message has been deleted, and if so, stops the collector with the reason 'messageDelete'. Parameters

NameTypeDescription
messageMessageThe message that was deleted

Returns: voidSource

_handleChannelDeletion

private

_handleChannelDeletion(channel: GuildChannel): void

Handles checking if the channel has been deleted, and if so, stops the collector with the reason 'channelDelete'. Parameters

NameTypeDescription
channelGuildChannelThe channel that was deleted

Returns: voidSource

_handleThreadDeletion

private

_handleThreadDeletion(thread: ThreadChannel): void

Handles checking if the thread has been deleted, and if so, stops the collector with the reason 'threadDelete'. Parameters

NameTypeDescription
threadThreadChannelThe thread that was deleted

Returns: voidSource

_handleGuildDeletion

private

_handleGuildDeletion(guild: Guild): void

Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'. Parameters

NameTypeDescription
guildGuildThe guild that was deleted

Returns: voidSource

handleCollect

async

async handleCollect(args: *): Promise<void>

Call this to handle an event as a collectable element. Accepts any event data as parameters. Parameters

NameTypeDescription
args*The arguments emitted by the listener

Returns: Promise<void>Source

handleDispose

async

async handleDispose(args: *): Promise<void>

Call this to remove an element from the collection. Accepts any event data as parameters. Parameters

NameTypeDescription
args*The arguments emitted by the listener

Returns: Promise<void>Source

stop

stop(reason?: string)

Stops this collector and emits the end event. Parameters

NameTypeDescription
reason?stringThe reason this collector is ending Default: 'user'.
Source

resetTimer

resetTimer(options?: CollectorResetTimerOptions)

Resets the collector's timeout and idle timer. Parameters

NameTypeDescription
options?CollectorResetTimerOptionsOptions for resetting
Source

checkEnd

checkEnd(): boolean

Checks whether the collector should end, and if so, ends it. Returns: boolean — Whether the collector ended or not Source

key

static

key(reaction: MessageReaction): Snowflakestring

Gets the collector key for a reaction. Parameters

NameTypeDescription
reactionMessageReactionThe message reaction to get the key for

Returns: SnowflakestringSource

Events

create

create: unknown

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

NameTypeDescription
reactionMessageReactionThe reaction that was added
userUserThe user that added the reaction
Source

collect

collect: unknown

Emitted whenever a reaction is collected. Parameters

NameTypeDescription
reactionMessageReactionThe reaction that was collected
userUserThe user that added the reaction
Source

dispose

dispose: unknown

Emitted when the reaction had all the users removed and the dispose option is set to true. Parameters

NameTypeDescription
reactionMessageReactionThe reaction that was disposed of
userUserThe user that removed the reaction
Source

remove

remove: unknown

Emitted when the reaction had one user removed and the dispose option is set to true. Parameters

NameTypeDescription
reactionMessageReactionThe reaction that was removed
userUserThe user that removed the reaction
Source

end

end: unknown

Emitted when the collector is finished collecting. Parameters

NameTypeDescription
collectedCollectionThe elements collected by the collector
reasonstringThe reason the collector ended
Source

Unofficial software. Not affiliated with or supported by Discord.