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

Represents user presence, e.g. what game they are playing and if they are online. More...

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

Public Member Functions

 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. More...
 
 presence (presence_status status, const activity &a)
 Construct a new presence object with some parameters for sending to a websocket. More...
 
 ~presence ()
 
presence_status desktop_status () const
 The users status on desktop. More...
 
presence_status web_status () const
 The user's status on web. 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...
 
presencefill_from_json (nlohmann::json *j)
 Convert object from nlohmann::json. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. More...
 

Public Attributes

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

Protected Member Functions

presencefill_from_json_impl (nlohmann::json *j)
 
virtual json to_json_impl (bool with_id=false) const
 

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

◆ 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

◆ ~presence()

dpp::presence::~presence ( )

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()

virtual 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

◆ 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.

◆ 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.

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