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

Search
Loading...
Searching...
No Matches
dpp::presence Class Reference

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

`#include <presence.h>`

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

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

## Public Attributes

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

## Protected Member Functions

presence & | fill_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

  status | Status of the activity
  type | Type of activity
  activity_description | Description 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

  status | Status of the activity
  a | Activity itself

## ◆ ~presence()

dpp::presence::~presence | ( |  | ) |

Destructor

## Member Function Documentation

## ◆ build_json()

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

inline inherited

Convert object to json string.

Parameters

  with_id | Whether 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 | ) |

inline inherited

Convert object from nlohmann::json.

Parameters

  j | nlohmann::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

  j | JSON 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_id | Add ID to output

Returns
  The JSON of the presence

## ◆ to_json_impl()

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

protected virtual

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_id | Add 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 Symbol 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.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