D++ (DPP)
C++ Discord API Bot Library
|
A definition of a discord entitlement. More...
Public Member Functions | |
entitlement ()=default | |
Construct a new entitlement object. More... | |
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. More... | |
entitlement_type | get_type () const |
Get the type of entitlement. More... | |
bool | is_consumed () const |
Was the entitlement consumed? More... | |
bool | is_deleted () const |
Was the entitlement deleted? More... | |
constexpr double | get_creation_time () const noexcept |
Get the creation time of this object according to Discord. More... | |
constexpr bool | operator== (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
constexpr bool | operator!= (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
entitlement & | fill_from_json (nlohmann::json *j) |
Convert object from nlohmann::json. More... | |
auto | to_json (bool with_id=false) const |
Convert object to nlohmann::json. More... | |
std::string | build_json (bool with_id=false) const |
Convert object to json string. More... | |
Public Attributes | |
snowflake | sku_id {0} |
ID of the entitlement event. More... | |
snowflake | application_id {0} |
ID of the parent application. More... | |
snowflake | subscription_id {0} |
Subscription ID. More... | |
snowflake | promotion_id {0} |
Promotion id. More... | |
uint8_t | gift_code_flags {0} |
Gift Code Flags (undocumented) More... | |
snowflake | user_id {0} |
Optional: ID of the user that is granted access to the entitlement's SKU. More... | |
snowflake | guild_id {0} |
Optional: ID of the user that is granted access to the entitlement's SKU. More... | |
entitlement_type | type = entitlement_type::APPLICATION_SUBSCRIPTION |
The type of entitlement. More... | |
time_t | starts_at {0} |
Optional: Start date at which the entitlement is valid. More... | |
time_t | ends_at {0} |
Optional: Date at which the entitlement is no longer valid. More... | |
uint16_t | flags {0} |
Flags bitmap from dpp::entitlement_flags. More... | |
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. More... | |
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. More... | |
Friends | |
struct | json_interface< entitlement > |
A definition of a discord entitlement.
An entitlement is a user's connection to an SKU, basically a subscription or a one-off purchase.
|
default |
Construct a new entitlement object.
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.
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. |
|
inlineinherited |
Convert object to json string.
with_id | Whether to include the ID or not |
|
inlineinherited |
Convert object from nlohmann::json.
j | nlohmann::json object |
|
protected |
Read class values from json object
j | A json object to read from |
|
inlineconstexprnoexceptinherited |
Get the creation time of this object according to Discord.
entitlement_type dpp::entitlement::get_type | ( | ) | const |
Get the type of entitlement.
bool dpp::entitlement::is_consumed | ( | ) | const |
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.
bool dpp::entitlement::is_deleted | ( | ) | const |
Was the entitlement deleted?
|
inlineconstexprnoexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
|
inlineconstexprnoexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
|
inlineinherited |
Convert object to nlohmann::json.
with_id | Whether to include the ID or not |
Build json for this entitlement object.
with_id | include the ID in the json |
|
friend |
snowflake dpp::entitlement::application_id {0} |
ID of the parent application.
time_t dpp::entitlement::ends_at {0} |
Optional: Date at which the entitlement is no longer valid.
uint16_t dpp::entitlement::flags {0} |
Flags bitmap from dpp::entitlement_flags.
uint8_t dpp::entitlement::gift_code_flags {0} |
Gift Code Flags (undocumented)
Undocumented, but given in examples in the docs.
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.
|
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.
snowflake dpp::entitlement::promotion_id {0} |
Promotion id.
These are undocumented but given in examples in the docs.
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.
time_t dpp::entitlement::starts_at {0} |
Optional: Start date at which the entitlement is valid.
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.
entitlement_type dpp::entitlement::type = entitlement_type::APPLICATION_SUBSCRIPTION |
The type of entitlement.
snowflake dpp::entitlement::user_id {0} |
Optional: ID of the user that is granted access to the entitlement's SKU.