Skip to main content
Collectors let you wait for one or more messages or reactions that satisfy a condition, without blocking the main event handler. They are created via client methods and operate as independent async tasks.

EndReason

Returned alongside the result from .collect(). Indicates why collection ended.

MessageCollector

Collects messages from a specified channel.

MessageCollectorOptions

Creating

Called on &mut Client. Registers an internal sender through which the client delivers incoming messages to the collector.

Collecting

Blocks the current task until the timeout expires, the limit is reached, or the channel closes. Returns all collected messages and the reason for completion.
.collect() consumes the collector. If you need multiple independent collection passes - create a new collector each time.

ReactionCollector

Collects reactions on a specified message.

ReactionCollectorOptions

Creating

Collecting

CollectedReaction

Structure delivered to the collector from the MessageReactionAdd event.

key()

Returns a unique reaction key in the format user_id:emoji_name:emoji_id (for custom emoji) or user_id:emoji_name (for Unicode). Useful for deduplication.

Architecture

Collectors work via mpsc::UnboundedSender. When a collector is created, the client stores its sender internally. On every MessageCreate or MessageReactionAdd, the client fans out data to all registered senders.
Senders remain in the client even after .collect() completes. Over time, dead senders accumulate. This does not cause a memory leak - sending to a closed channel is silently ignored - but it adds minor overhead to the event handler when a large number of completed collectors have built up.