Preview environment

class InteractionCollector

extends

Collector<Snowflake, Interaction, [Collection<Snowflake, Interaction>]>
export class InteractionCollector<Interaction extends CollectedInteraction> extends Collector<Snowflake, Interaction, [Collection<Snowflake, Interaction>]>

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.

Constructors

constructor(
client: Client<true>
options?: InteractionCollectorOptions<Interaction>
)

Type Parameters

Interaction extends CollectedInteraction

channelId : Snowflake | null

The channel from which to collect interactions, if provided

readonly
client : Client

The client that instantiated this Collector

Inherited from: Collector

collected : Collection<Snowflake, Interaction>

The items collected by this collector

Inherited from: Collector

componentType : ComponentType | null

The type of component to collect

ended : boolean

Whether this collector has finished collecting

Inherited from: Collector

readonly
endReason : string | null

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

Inherited from: Collector

filter : CollectorFilter<[Interaction, ...[]>

The filter applied to this collector

Inherited from: Collector

guildId : Snowflake | null

The guild from which to collect interactions, if provided

interactionType : InteractionType | null

The type of interaction to collect

readonly
lastCollectedAt : Date | null

The Date at which this collector last collected an item

Inherited from: Collector

lastCollectedTimestamp : number | null

The timestamp at which this collector last collected an item

Inherited from: Collector

protected
listener : (...args: any[]) => void

Inherited from: Collector

messageId : Snowflake | null

The message from which to collect interactions, if provided

messageInteractionId : Snowflake | null

The message interaction id from which to collect interactions, if provided

readonly
next : Promise<Interaction>

Returns a promise that resolves with the next collected element; rejects with collected elements if the collector finishes without receiving a next element

Inherited from: Collector

options : InteractionCollectorOptions<Interaction>

The options of this collector

total : number

The total number of interactions collected

The users that have interacted with this collector

[Symbol.asyncIterator]() : AsyncIterableIterator<[Interaction, ...[]>

Inherited from: Collector

checkEnd() : boolean

Checks whether the collector should end, and if so, ends it.

Returns: Whether the collector ended or not

Inherited from: Collector

collect(
interaction: Interaction
) : Snowflake

Handles an incoming interaction for possible collection.

dispose(
interaction: Interaction
) : Snowflake

Handles an interaction for possible disposal.

empty() : void

Empties this interaction collector.

handleCollect(
...args: unknown[]
) : Promise<void>

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

Inherited from: Collector

handleDispose(
...args: unknown[]
) : Promise<void>

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

Inherited from: Collector

on(
event: 'collect' | 'dispose' | 'ignore'
listener: (interaction: Interaction) => void
) : this

once(
event: 'collect' | 'dispose' | 'ignore'
listener: (interaction: Interaction) => void
) : this

resetTimer() : void

Resets the collector's timeout and idle timer.

Inherited from: Collector

stop(
reason?: string
) : void

Stops this collector and emits the end event.

Inherited from: Collector

toJSON() : unknown

Inherited from: Collector

collect(
interaction: BaseInteraction
)

Emitted whenever an interaction is collected.

dispose(
interaction: BaseInteraction
)

Emitted whenever an interaction is disposed of.

end(
collected: Collection
reason: string
)

Emitted when the collector is finished collecting.

ignore(
args: any
)

Emitted whenever an element is not collected by the collector.