Abstract

Collector

export abstract class Collector<K, V, F extends unknown[] = []> extends EventEmitter
export abstract class Collector<K, V, F extends unknown[] = []> extends EventEmitter
Abstract class for defining a new Collector.

Extends

EventEmitter
NameConstraintsOptionalDefaultDescription
KNoNone
VNoNone
Funknown[]Yes[]None
constructor(client, options?)
Constructs a new instance of the Collector class
NameTypeOptionalDescription
clientClient<true>NoNone
optionsCollectorOptions<[V, ...F]>YesNone
collect(args)
Emitted whenever an element is collected.
NameTypeOptionalDescription
args*NoThe arguments emitted by the listener
dispose(args)
Emitted whenever an element is disposed of.
NameTypeOptionalDescription
args*NoThe arguments emitted by the listener
end(collected, reason)
Emitted when the collector is finished collecting.
NameTypeOptionalDescription
collectedCollectionNoThe elements collected by the collector
reasonstringNoThe reason the collector ended
ignore(args)
Emitted whenever an element is not collected by the collector.
NameTypeOptionalDescription
args*NoThe arguments emitted by the listener
Readonly
client:Client
The client that instantiated this Collector
collected:Collection<K, V>
The items collected by this collector
ended:boolean
Whether this collector has finished collecting
Readonly
endReason:string | null
The reason this collector has ended with, or null if it hasn't ended yet
filter:CollectorFilter<[V, ...F]>
The filter applied to this collector
Readonly
lastCollectedAt:Date | null
The Date at which this collector last collected an item
lastCollectedTimestamp:number | null
The timestamp at which this collector last collected an item
Protected
listener:(...args: any[]) => void
options:CollectorOptions<[V, ...F]>
The options of this collector
[Symbol.asyncIterator]():AsyncIterableIterator<[V, ...F]>
checkEnd():boolean
Checks whether the collector should end, and if so, ends it.
Returns
Whether the collector ended or not
Abstract
collect(...args):K | null | Promise<K | null>
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.
Returns
Data to insert into collection, if any
NameTypeOptionalDescription
...argsunknown[]NoAny args the event listener emits
Abstract
dispose(...args):K | null
Handles incoming events from the handleDispose. Returns null if the event should not be disposed, or returns the key that should be removed.
Returns
Key to remove from the collection, if any
NameTypeOptionalDescription
...argsunknown[]NoAny args the event listener emits
handleCollect(...args):Promise<void>
Call this to handle an event as a collectable element. Accepts any event data as parameters.
NameTypeOptionalDescription
...argsunknown[]NoThe arguments emitted by the listener
handleDispose(...args):Promise<void>
Call this to remove an element from the collection. Accepts any event data as parameters.
NameTypeOptionalDescription
...argsunknown[]NoThe arguments emitted by the listener
on(event, listener):this
NameTypeOptionalDescription
eventEventKeyNoNone
listener(...args: CollectorEventTypes<K, V, F>[EventKey]) => Awaitable<void>NoNone
once(event, listener):this
NameTypeOptionalDescription
eventEventKeyNoNone
listener(...args: CollectorEventTypes<K, V, F>[EventKey]) => Awaitable<void>NoNone
resetTimer(options?):void
Resets the collector's timeout and idle timer.
NameTypeOptionalDescription
optionsCollectorResetTimerOptionsYesOptions for resetting
stop(reason?):void
Stops this collector and emits the end event.
NameTypeOptionalDescription
reasonstringYesThe reason this collector is ending
toJSON():unknown