| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
dpp::message_collector Class Referenceabstract

Message collector. Collects messages during a set timeframe and returns them in a list via the completed() method. More...

`#include <collector.h>`

Inheritance diagram for dpp::message_collector:
[legend]
Collaboration diagram for dpp::message_collector:
[legend]

## Public Member Functions

| message_collector (cluster *cl, uint64_t duration)
| Construct a new message collector object.
virtual | ~message_collector ()=default
| Destroy the message collector object.
virtual void | cancel ()
| Immediately cancels the collector.
virtual void | completed (const std::vector< dpp::message > &list)=0
| Return the completed collection.
virtual const dpp::message * | filter (const dpp::message_create_t &element)
| Select and filter the items which are to appear in the list This is called every time a new event is fired, to filter the event and determine which of the items is sent to the list. Returning nullptr excludes the item from the list.

## Protected Attributes

class cluster * | owner
| Owning cluster.

## Detailed Description

Message collector. Collects messages during a set timeframe and returns them in a list via the completed() method.

## Constructor & Destructor Documentation

## ◆ message_collector()

dpp::message_collector::message_collector | ( | cluster * | cl,
|  | uint64_t | duration )

inline

Construct a new message collector object.

Parameters

  cl | cluster to associate the collector with
  duration | Duration of time to run the collector for in seconds

## ◆ ~message_collector()

virtual dpp::message_collector::~message_collector | ( |  | ) |

virtual default

Destroy the message collector object.

## Member Function Documentation

## ◆ cancel()

virtual void dpp::collector< dpp::message_create_t, dpp::message >::cancel | ( |  | ) |

inline virtual inherited

Immediately cancels the collector.

Use this if you have met the conditions for which you are collecting objects early, e.g. you were watching for a message containing 'yes' or 'no' and have received it before the time is up.

Note
  Causes calling of the completed() method if it has not yet been called.

## ◆ completed()

virtual void dpp::message_collector::completed | ( | const std::vector< dpp::message > & | list | ) |

pure virtual

Return the completed collection.

Parameters

  list | items collected during the timeframe specified

Implements dpp::collector< dpp::message_create_t, dpp::message >.

## ◆ filter()

virtual const dpp::message * dpp::message_collector::filter | ( | const dpp::message_create_t & | element | ) |

inline virtual

Select and filter the items which are to appear in the list This is called every time a new event is fired, to filter the event and determine which of the items is sent to the list. Returning nullptr excludes the item from the list.

Parameters

  element | element to filter

Returns
  Returned item to add to the list, or nullptr to skip adding this element

Implements dpp::collector< dpp::message_create_t, dpp::message >.

## Member Data Documentation

## ◆ owner

class cluster* dpp::collector< dpp::message_create_t, dpp::message >::owner

protected inherited

Owning cluster.

D++ Library version 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0