Skip to content

Collector

classe · Source

Abstract class for defining a new Collector.

Extends: EventEmitter

Properties

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

endReason

readonly · nullable · abstract

endReason: string

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

Methods

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

collect

abstract

collect(args: *): * | Promise<?*>

Handles incoming events from the handleCollect function. Returns null if the event should not be collected, or returns an object describing the data that should be stored. Parameters

NameTypeDescription
args*Any args the event listener emits

Returns: * \| Promise<?*> — Data to insert into collection, if any Source

dispose

abstract

dispose(args: *): *

Handles incoming events from the handleDispose. Returns null if the event should not be disposed, or returns the key that should be removed. Parameters

NameTypeDescription
args*Any args the event listener emits

Returns: * — Key to remove from the collection, if any Source

Events

collect

collect: unknown

Emitted whenever an element is collected. Parameters

NameTypeDescription
args*The arguments emitted by the listener
Source

dispose

dispose: unknown

Emitted whenever an element is disposed of. Parameters

NameTypeDescription
args*The arguments emitted by the listener
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.