D++ (DPP)
C++ Discord API Bot Library
dpp::role_collector Class Referenceabstract

Role collector. Collects guild roles during a set timeframe and returns them in a list via the completed() method. More...

#include <dpp.h>

+ Inheritance diagram for dpp::role_collector:
+ Collaboration diagram for dpp::role_collector:

Public Member Functions

 role_collector (cluster *cl, uint64_t duration)
 Construct a new role collector object. More...
 
virtual void completed (const std::vector< dpp::role > &list)=0
 Return the completed collection. More...
 
virtual const dpp::rolefilter (const dpp::guild_role_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. More...
 
virtual ~role_collector ()=default
 Destroy the role collector object. More...
 
virtual void completed (const std::vector< C > &list)=0
 You must implement this function to receive the completed list of captured objects. More...
 
virtual const C * filter (const T &element)=0
 Filter the list of elements. More...
 
virtual void cancel ()
 Immediately cancels the collector. More...
 

Protected Attributes

class clusterowner
 Owning cluster. More...
 

Detailed Description

Role collector. Collects guild roles during a set timeframe and returns them in a list via the completed() method.

Constructor & Destructor Documentation

◆ role_collector()

dpp::role_collector::role_collector ( cluster cl,
uint64_t  duration 
)
inline

Construct a new role collector object.

Parameters
clcluster to associate the collector with
durationDuration of time to run the collector for in seconds

◆ ~role_collector()

virtual dpp::role_collector::~role_collector ( )
virtualdefault

Destroy the role collector object.

Member Function Documentation

◆ cancel()

template<class T , class C >
virtual void dpp::collector< T, C >::cancel ( )
inlinevirtualinherited

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() [1/2]

template<class T , class C >
virtual void dpp::collector< T, C >::completed ( const std::vector< C > &  list)
pure virtualinherited

You must implement this function to receive the completed list of captured objects.

Parameters
listThe list of captured objects in captured order

◆ completed() [2/2]

virtual void dpp::role_collector::completed ( const std::vector< dpp::role > &  list)
pure virtual

Return the completed collection.

Parameters
listitems collected during the timeframe specified

◆ filter() [1/2]

virtual const dpp::role * dpp::role_collector::filter ( const dpp::guild_role_create_t element)
inlinevirtual

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
elementelement to filter
Returns
Returned item to add to the list, or nullptr to skip adding this element

◆ filter() [2/2]

template<class T , class C >
virtual const C * dpp::collector< T, C >::filter ( const T &  element)
pure virtualinherited

Filter the list of elements.

Every time an event is fired on the collector, this method wil be called to determine if we should add an object to the list or not. This function can then process the element value, extract the parts which are to be saved to a list (e.g. a dpp::message out of a dpp::message_create_t) and return it as the return value. Returning a value of nullptr causes no object to be stored.

Here is an example of how to filter messages which have specific text in them. This should be used with the specialised type dpp::message_collector

virtual const dpp::message* filter(const dpp::message_create_t& m) {
if (m.msg.content.find("something i want") != std::string::npos) {
return &m.msg;
} else {
return nullptr;
}
}
virtual const dpp::role * filter(const dpp::guild_role_create_t &element)
Select and filter the items which are to appear in the list This is called every time a new event is ...
Definition: dpp.h:317
Create message.
Definition: dispatcher.h:1354
message msg
message that was created (sent).
Definition: dispatcher.h:1363
Represents messages sent and received on Discord.
Definition: message.h:1107
std::string content
Definition: message.h:1117
Parameters
elementThe event data to filter
Returns
const C* Returned object or nullptr

Member Data Documentation

◆ owner

template<class T , class C >
class cluster* dpp::collector< T, C >::owner
protectedinherited

Owning cluster.

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0