Skip to main content
Version: 0.8.0

Class: MessageCollector

Collects messages on a channel.

Extends​

Constructors​

Constructor​

new MessageCollector(channel, options?): MessageCollector

Parameters​

ParameterType
channelBaseChannel
optionsMessageCollectorOptions

Returns​

MessageCollector

Overrides​

Collector.constructor

Properties​

channel​

channel: BaseChannel


channelId​

channelId: string


client​

readonly client: Client

Inherited from​

Collector.client


collected​

collected: Collection<string, Message>

Inherited from​

Collector.collected


ended​

ended: boolean = false

Inherited from​

Collector.ended


filter​

filter: (item, ...args) => boolean

Parameters​

ParameterType
itemMessage
...argsany[]

Returns​

boolean

Inherited from​

Collector.filter


options​

options: CollectorOptions<Message>

Inherited from​

Collector.options


processed​

processed: number = 0


total​

total: number = 0

Methods​

[asyncIterator]()​

[asyncIterator](): AsyncIterableIterator<[string, Message]>

Allows iterating over collected items asynchronously.

Returns​

AsyncIterableIterator<[string, Message]>

Example​

for await (const [id, message] of collector) {
console.log(`Received message: ${message.content}`);
}

Inherited from​

Collector.[asyncIterator]


checkEnd()​

checkEnd(): void

Check if we should end upon collecting/disposing

Returns​

void

Inherited from​

Collector.checkEnd


collect()​

collect(message): string | null

Returns a key if the item should be collected, or null to skip

Parameters​

ParameterType
messageMessage

Returns​

string | null

Overrides​

Collector.collect


dispose()​

dispose(message): string | null

Returns a key if the item should be disposed, or null to skip

Parameters​

ParameterType
messageMessage | { channelId: string; id: string; }

Returns​

string | null

Overrides​

Collector.dispose


endReason()​

endReason(): string | null

Check if there's a reason to end

Returns​

string | null

Overrides​

Collector.endReason


handleCollect()​

handleCollect(message): void

Evaluates an item and possibly passes it to the collector

Parameters​

ParameterType
messageMessage

Returns​

void

Overrides​

Collector.handleCollect


handleDispose()​

handleDispose(item, ...args): void

Evaluates an item and possibly removes it from the collector

Parameters​

ParameterType
itemMessage
...argsany[]

Returns​

void

Inherited from​

Collector.handleDispose


stop()​

stop(reason?): void

Stops the collector.

Parameters​

ParameterTypeDefault value
reasonstring"user"

Returns​

void

Inherited from​

Collector.stop