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

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

A definition of a discord entitlement. More...

`#include <entitlement.h>`

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

## Public Member Functions

| entitlement ()=default
| Construct a new entitlement object.
| entitlement (const snowflake sku_id, const snowflake id=0, const snowflake application_id=0, const entitlement_type type=dpp::entitlement_type::APPLICATION_SUBSCRIPTION, const uint8_t flags=0)
| Construct a new entitlement object with sku_id, ID, application_id, type, and flags.
std::string | build_json (bool with_id=false) const
| Convert object to json string.
entitlement & | fill_from_json (nlohmann::json *j)
| Convert object from nlohmann::json.
constexpr double | get_creation_time () const noexcept
| Get the creation time of this object according to Discord.
entitlement_type | get_type () const
| Get the type of entitlement.
bool | is_consumed () const
| Was the entitlement consumed?
bool | is_deleted () const
| Was the entitlement deleted?
constexpr bool | operator!= (const managed &other) const noexcept
| Comparison operator for comparing two managed objects by id.
constexpr bool | operator== (const managed &other) const noexcept
| Comparison operator for comparing two managed objects by id.
auto | to_json (bool with_id=false) const
| Convert object to nlohmann::json.

## Public Attributes

snowflake | application_id {0}
| ID of the parent application.
time_t | ends_at {0}
| Optional: Date at which the entitlement is no longer valid.
uint16_t | flags {0}
| Flags bitmap from dpp::entitlement_flags.
uint8_t | gift_code_flags {0}
| Gift Code Flags (undocumented).
snowflake | guild_id {0}
| Optional: ID of the user that is granted access to the entitlement's SKU.
snowflake | id = {}
| Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata.
snowflake | promotion_id {0}
| Promotion id.
snowflake | sku_id {0}
| ID of the entitlement event.
time_t | starts_at {0}
| Optional: Start date at which the entitlement is valid.
snowflake | subscription_id {0}
| Subscription ID.
entitlement_type | type = entitlement_type::APPLICATION_SUBSCRIPTION
| The type of entitlement.
snowflake | user_id {0}
| Optional: ID of the user that is granted access to the entitlement's SKU.

## Protected Member Functions

entitlement & | fill_from_json_impl (nlohmann::json *j)
json | to_json_impl (bool with_id=false) const
| Build json for this entitlement object.

## Friends

struct | json_interface< entitlement >

## Detailed Description

A definition of a discord entitlement.

An entitlement is a user's connection to an SKU, basically a subscription or a one-off purchase.

## Constructor & Destructor Documentation

## ◆ entitlement() [1/2]

dpp::entitlement::entitlement | ( |  | ) |

default

Construct a new entitlement object.

## ◆ entitlement() [2/2]

dpp::entitlement::entitlement | ( | const snowflake | sku_id,
|  | const snowflake | id = 0,
|  | const snowflake | application_id = 0,
|  | const entitlement_type | type = dpp::entitlement_type::APPLICATION_SUBSCRIPTION,
|  | const uint8_t | flags = 0 )

Construct a new entitlement object with sku_id, ID, application_id, type, and flags.

Parameters

  sku_id | The ID of the SKU.
  id | The ID of the entitlement.
  application_id | The ID of the parent application.
  type | The type of entitlement (Should only ever be APPLICATION_SUBSCRIPTION unless you going to use this object as a parameter for dpp::cluster::entitlement_test_create).
  flags | The flags for the SKU from dpp::entitlement_flags.

## Member Function Documentation

## ◆ build_json()

std::string dpp::json_interface< entitlement >::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

## ◆ fill_from_json()

entitlement & dpp::json_interface< entitlement >::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()

entitlement & dpp::entitlement::fill_from_json_impl | ( | nlohmann::json * | j | ) |

protected

Read class values from json object

Parameters

  j | A json object to read from

Returns
  A reference to self

## ◆ get_creation_time()

double dpp::managed::get_creation_time | ( |  | ) | const

inline constexpr noexcept inherited

Get the creation time of this object according to Discord.

Returns
  double creation time inferred from the snowflake ID. The minimum possible value is the first second of 2015.

## ◆ get_type()

entitlement_type dpp::entitlement::get_type | ( |  | ) | const

nodiscard

Get the type of entitlement.

Returns
  entitlement_type Entitlement type

## ◆ is_consumed()

bool dpp::entitlement::is_consumed | ( |  | ) | const

nodiscard

Was the entitlement consumed?

A consumed entitlement is a one off purchase which has been claimed as used by the application. for example in-app purchases.

Returns
  true if the entitlement was consumed.

## ◆ is_deleted()

bool dpp::entitlement::is_deleted | ( |  | ) | const

nodiscard

Was the entitlement deleted?

Returns
  true if the entitlement was deleted.

## ◆ operator!=()

bool dpp::managed::operator!= | ( | const managed & | other | ) | const

inline constexpr noexcept inherited

Comparison operator for comparing two managed objects by id.

Parameters

  other | Other object to compare against

Returns
  true objects are not the same id
  false objects are the same id

## ◆ operator==()

bool dpp::managed::operator== | ( | const managed & | other | ) | const

inline constexpr noexcept inherited

Comparison operator for comparing two managed objects by id.

Parameters

  other | Other object to compare against

Returns
  true objects are the same id
  false objects are not the same id

## ◆ to_json()

auto dpp::json_interface< entitlement >::to_json | ( | bool | with_id = false | ) | const

inline inherited

Convert object to nlohmann::json.

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
  json Json built from the structure

## ◆ to_json_impl()

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

protected

Build json for this entitlement object.

Parameters

  with_id | include the ID in the json

Returns
  json JSON object

## Friends And Related Symbol Documentation

## ◆ json_interface< entitlement >

friend struct json_interface< entitlement >

friend

## Member Data Documentation

## ◆ application_id

snowflake dpp::entitlement::application_id {0}

ID of the parent application.

## ◆ ends_at

time_t dpp::entitlement::ends_at {0}

Optional: Date at which the entitlement is no longer valid.

Note
  Not present when using test entitlements.

## ◆ flags

uint16_t dpp::entitlement::flags {0}

Flags bitmap from dpp::entitlement_flags.

## ◆ gift_code_flags

uint8_t dpp::entitlement::gift_code_flags {0}

Gift Code Flags (undocumented).

Undocumented, but given in examples in the docs.

## ◆ guild_id

snowflake dpp::entitlement::guild_id {0}

Optional: ID of the user that is granted access to the entitlement's SKU.

If a guild is provided, according to the examples the user who triggered the purchase will also be passed in the user ID. The presence of a non-zero guild id snowflake is indication it is a guild subscription.

## ◆ id

snowflake dpp::managed::id = {}

inherited

Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata.

## ◆ promotion_id

snowflake dpp::entitlement::promotion_id {0}

Promotion id.

These are undocumented but given in examples in the docs.

## ◆ sku_id

snowflake dpp::entitlement::sku_id {0}

ID of the entitlement event.

Not sure if this remains constant, it does not relate to the SKU, user, guild or subscription. Do not use it for anything except state tracking.

## ◆ starts_at

time_t dpp::entitlement::starts_at {0}

Optional: Start date at which the entitlement is valid.

Note
  Not present when using test entitlements.

## ◆ subscription_id

snowflake dpp::entitlement::subscription_id {0}

Subscription ID.

This is a unique identifier of the user or guilds subscription to the SKU. It won't ever change.

## ◆ type

entitlement_type dpp::entitlement::type = entitlement_type::APPLICATION_SUBSCRIPTION

The type of entitlement.

## ◆ user_id

snowflake dpp::entitlement::user_id {0}

Optional: ID of the user that is granted access to the entitlement's SKU.

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