D++ (DPP)
C++ Discord API Bot Library
dpp::event_dispatch_t Struct Reference

Base event parameter struct. Each event you receive from the library will have its parameter derived from this class. The class contains the raw event data, and a pointer to the current shard's dpp::discord_client object. You can also use this object to cancel the current event, meaning that any listeners after yours do not get notified of the current event if you call it. More...

#include <dispatcher.h>

+ Inheritance diagram for dpp::event_dispatch_t:
+ Collaboration diagram for dpp::event_dispatch_t:

Public Member Functions

 event_dispatch_t ()=default
 Construct a new event_dispatch_t object. More...
 
 event_dispatch_t (const event_dispatch_t &rhs)=default
 Construct a new event_dispatch_t object. More...
 
 event_dispatch_t (event_dispatch_t &&rhs)=default
 Construct a new event_dispatch_t object. More...
 
 event_dispatch_t (discord_client *client, const std::string &raw)
 Construct a new event_dispatch_t object. More...
 
 event_dispatch_t (discord_client *client, std::string &&raw)
 Construct a new event_dispatch_t object. More...
 
event_dispatch_toperator= (const event_dispatch_t &rhs)=default
 Copy another event_dispatch_t object. More...
 
event_dispatch_toperator= (event_dispatch_t &&rhs)=default
 Move from another event_dispatch_t object. More...
 
virtual ~event_dispatch_t ()=default
 Destroy an event_dispatch_t object Protected because this object is to be derived from. More...
 
const event_dispatch_tcancel_event () const
 Cancels the event in progress. Any other attached lambdas for this event after this one are not called. More...
 
event_dispatch_tcancel_event ()
 Cancels the event in progress. Any other attached lambdas for this event after this one are not called. More...
 
bool is_cancelled () const
 Returns true if the event is cancelled. Note that event cancellation is a thread local state, and not stored in the object (because object which can be cancelled is const during the event, and cannot itself contain the changeable state). More...
 

Public Attributes

std::string raw_event = {}
 Raw event data. If you are using json on your websocket, this will contain json, and if you are using ETF as your websocket protocol, it will contain raw ETF data. More...
 
discord_clientfrom = nullptr
 Shard the event came from. Note that for some events, notably voice events, this may be nullptr. More...
 
bool cancelled = false
 Whether the event was cancelled using cancel_event(). More...
 

Detailed Description

Base event parameter struct. Each event you receive from the library will have its parameter derived from this class. The class contains the raw event data, and a pointer to the current shard's dpp::discord_client object. You can also use this object to cancel the current event, meaning that any listeners after yours do not get notified of the current event if you call it.

Constructor & Destructor Documentation

◆ event_dispatch_t() [1/5]

dpp::event_dispatch_t::event_dispatch_t ( )
default

Construct a new event_dispatch_t object.

◆ event_dispatch_t() [2/5]

dpp::event_dispatch_t::event_dispatch_t ( const event_dispatch_t rhs)
default

Construct a new event_dispatch_t object.

Parameters
rhsevent_dispatch_t object to copy from

◆ event_dispatch_t() [3/5]

dpp::event_dispatch_t::event_dispatch_t ( event_dispatch_t &&  rhs)
default

Construct a new event_dispatch_t object.

Parameters
rhsevent_dispatch_t object to move from

◆ event_dispatch_t() [4/5]

dpp::event_dispatch_t::event_dispatch_t ( discord_client client,
const std::string &  raw 
)

Construct a new event_dispatch_t object.

Parameters
clientThe shard the event originated on. May be a nullptr, e.g. for voice events
rawRaw event data as JSON or ETF

◆ event_dispatch_t() [5/5]

dpp::event_dispatch_t::event_dispatch_t ( discord_client client,
std::string &&  raw 
)

Construct a new event_dispatch_t object.

Parameters
clientThe shard the event originated on. May be a nullptr, e.g. for voice events
rawRaw event data as JSON or ETF

◆ ~event_dispatch_t()

virtual dpp::event_dispatch_t::~event_dispatch_t ( )
virtualdefault

Destroy an event_dispatch_t object Protected because this object is to be derived from.

Member Function Documentation

◆ cancel_event() [1/2]

event_dispatch_t & dpp::event_dispatch_t::cancel_event ( )

Cancels the event in progress. Any other attached lambdas for this event after this one are not called.

Warning
This will modify the event object in a non-thread-safe manner.
Returns
const event_dispatch_t& reference to self for chaining

◆ cancel_event() [2/2]

const event_dispatch_t & dpp::event_dispatch_t::cancel_event ( ) const

Cancels the event in progress. Any other attached lambdas for this event after this one are not called.

Warning
This will modify the event object in a non-thread-safe manner.
Returns
const event_dispatch_t& reference to self for chaining

◆ is_cancelled()

bool dpp::event_dispatch_t::is_cancelled ( ) const

Returns true if the event is cancelled. Note that event cancellation is a thread local state, and not stored in the object (because object which can be cancelled is const during the event, and cannot itself contain the changeable state).

Returns
true if the event is cancelled

◆ operator=() [1/2]

event_dispatch_t & dpp::event_dispatch_t::operator= ( const event_dispatch_t rhs)
default

Copy another event_dispatch_t object.

Parameters
rhsThe event to copy from

◆ operator=() [2/2]

event_dispatch_t & dpp::event_dispatch_t::operator= ( event_dispatch_t &&  rhs)
default

Move from another event_dispatch_t object.

Parameters
rhsThe event to move from

Member Data Documentation

◆ cancelled

bool dpp::event_dispatch_t::cancelled = false
mutable

Whether the event was cancelled using cancel_event().

◆ from

discord_client* dpp::event_dispatch_t::from = nullptr

Shard the event came from. Note that for some events, notably voice events, this may be nullptr.

◆ raw_event

std::string dpp::event_dispatch_t::raw_event = {}

Raw event data. If you are using json on your websocket, this will contain json, and if you are using ETF as your websocket protocol, it will contain raw ETF data.

D++ 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