D++ (DPP)  10.0.30
C++ Discord API Bot Library
dpp::presence Class Reference

Represents user presence, e.g. More...

#include "presence.h"

Inheritance diagram for dpp::presence:
Collaboration diagram for dpp::presence:

Public Member Functions

 presence ()
 Constructor. More...
 
 presence (presence_status status, activity_type type, const std::string &activity_description)
 Construct a new presence object with some parameters for sending to a websocket. More...
 
 presence (presence_status status, const activity &a)
 Construct a new presence object with some parameters for sending to a websocket. More...
 
 ~presence ()
 Destructor. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. More...
 
presence_status desktop_status () const
 The users status on desktop. More...
 
presencefill_from_json (nlohmann::json *j)
 Convert object from nlohmann::json. More...
 
presence_status mobile_status () const
 The user's status on mobile. More...
 
presence_status status () const
 The user's status as shown to other users. More...
 
json to_json (bool with_id=false) const
 Build JSON from this object. More...
 
presence_status web_status () const
 The user's status on web. More...
 

Public Attributes

std::vector< activityactivities
 List of activities. More...
 
uint8_t flags
 Flags bitmask containing dpp::presence_flags. More...
 
snowflake guild_id
 Guild ID. More...
 
snowflake user_id
 The user the presence applies to. More...
 

Protected Member Functions

presencefill_from_json_impl (nlohmann::json *j)
 Fill this object from json. More...
 
virtual json to_json_impl (bool with_id=false) const
 Build JSON from this object. More...
 

Friends

struct json_interface< presence >
 

Detailed Description

Represents user presence, e.g.

what game they are playing and if they are online

Constructor & Destructor Documentation

◆ presence() [1/3]

dpp::presence::presence ( )

Constructor.

References flags, and dpp::p_status_online.

◆ presence() [2/3]

dpp::presence::presence ( presence_status  status,
activity_type  type,
const std::string &  activity_description 
)

Construct a new presence object with some parameters for sending to a websocket.

Parameters
statusStatus of the activity
typeType of activity
activity_descriptionDescription of the activity

◆ presence() [3/3]

dpp::presence::presence ( presence_status  status,
const activity a 
)

Construct a new presence object with some parameters for sending to a websocket.

Parameters
statusStatus of the activity
aActivity itself

References dpp::unicode_emoji::desktop, and dpp::string_not_null().

Here is the call graph for this function:

◆ ~presence()

dpp::presence::~presence ( )
default

Destructor.

Member Function Documentation

◆ build_json()

std::string dpp::json_interface< presence >::build_json ( bool  with_id = false) const
inlineinherited

Convert object to json string.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
std::string Json built from the structure

◆ desktop_status()

presence_status dpp::presence::desktop_status ( ) const

The users status on desktop.

Returns
The user's status on desktop

◆ fill_from_json()

presence & dpp::json_interface< presence >::fill_from_json ( nlohmann::json j)
inlineinherited

Convert object from nlohmann::json.

Parameters
jnlohmann::json object
Returns
T& Reference to self for fluent calling

◆ fill_from_json_impl()

presence & dpp::presence::fill_from_json_impl ( nlohmann::json j)
protected

Fill this object from json.

Parameters
jJSON object to fill from
Returns
A reference to self

◆ mobile_status()

presence_status dpp::presence::mobile_status ( ) const

The user's status on mobile.

Returns
The user's status on mobile

◆ status()

presence_status dpp::presence::status ( ) const

The user's status as shown to other users.

Returns
The user's status as shown to other users

◆ to_json()

json dpp::presence::to_json ( bool  with_id = false) const

Build JSON from this object.

Note
This excludes any part of the presence object that are not valid for websockets and bots, and includes websocket opcode 3. You will not get what you expect if you call this on a user's presence received from on_presence_update or on_guild_create!
Parameters
with_idAdd ID to output
Returns
The JSON of the presence

◆ to_json_impl()

json dpp::presence::to_json_impl ( bool  with_id = false) const
protectedvirtual

Build JSON from this object.

Note
This excludes any part of the presence object that are not valid for websockets and bots, and includes websocket opcode 3. You will not get what you expect if you call this on a user's presence received from on_presence_update or on_guild_create!
Parameters
with_idAdd ID to output
Returns
The JSON text of the presence

References dpp::at_custom.

◆ web_status()

presence_status dpp::presence::web_status ( ) const

The user's status on web.

Returns
The user's status on web

Friends And Related Function Documentation

◆ json_interface< presence >

friend struct json_interface< presence >
friend

Member Data Documentation

◆ activities

std::vector<activity> dpp::presence::activities

List of activities.

◆ flags

uint8_t dpp::presence::flags

Flags bitmask containing dpp::presence_flags.

Referenced by presence().

◆ guild_id

snowflake dpp::presence::guild_id

Guild ID.

Note
Apparently, Discord supports this internally, but the client doesn't...

◆ user_id

snowflake dpp::presence::user_id

The user the presence applies to.


The documentation for this class was generated from the following files: