![]() |
D++ (DPP)
C++ Discord API Bot Library
|
Represents a discord webhook. More...
#include <webhook.h>
Inheritance diagram for dpp::webhook:
Collaboration diagram for dpp::webhook:Public Member Functions | |
| webhook () | |
| Construct a new webhook object. More... | |
| webhook (const snowflake webhook_id, const std::string &webhook_token) | |
| Construct a new webhook object using the webhook ID and the webhook token. More... | |
| webhook (const std::string &webhook_url) | |
| Construct a new webhook object using the Webhook URL provided by Discord. More... | |
| std::string | build_json (bool with_id=false) const |
| Convert object to json string. More... | |
| webhook & | fill_from_json (nlohmann::json *j) |
| Convert object from nlohmann::json. More... | |
| constexpr double | get_creation_time () const noexcept |
| Get the creation time of this object according to Discord. More... | |
| webhook & | load_image (const std::string &image_blob, const image_type type, bool is_base64_encoded=false) |
| Base64 encode image data and allocate it to image_data. 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... | |
| auto | to_json (bool with_id=false) const |
| Convert object to nlohmann::json. More... | |
Public Attributes | |
| snowflake | application_id |
| The bot/OAuth2 application that created this webhook. More... | |
| utility::iconhash | avatar |
| The default avatar of the webhook. More... | |
| snowflake | channel_id |
| The channel id this webhook is for. More... | |
| snowflake | guild_id |
| The guild id this webhook is for. 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... | |
| std::string | image_data |
| base64 encoded image data if uploading a new image. More... | |
| std::string | name |
| The default name of the webhook. More... | |
| channel | source_channel |
| The channel that this webhook is following (only for Channel Follower Webhooks). More... | |
| guild | source_guild |
| The guild of the channel that this webhook is following (only for Channel Follower Webhooks). More... | |
| std::string | token |
| The secure token of the webhook (returned for Incoming Webhooks). More... | |
| uint8_t | type |
| Type of the webhook from dpp::webhook_type. More... | |
| std::string | url |
| The url used for executing the webhook (returned by the webhooks OAuth2 flow). More... | |
| user | user_obj |
| The user this webhook was created by. More... | |
Protected Member Functions | |
| webhook & | fill_from_json_impl (nlohmann::json *j) |
| Fill in object from json data. More... | |
| virtual json | to_json_impl (bool with_id=false) const |
| Build JSON string from object. More... | |
Friends | |
| struct | json_interface< webhook > |
Represents a discord webhook.
| dpp::webhook::webhook | ( | ) |
Construct a new webhook object.
| dpp::webhook::webhook | ( | const std::string & | webhook_url | ) |
Construct a new webhook object using the Webhook URL provided by Discord.
| webhook_url | a fully qualified web address of an existing webhook |
| logic_exception | if the webhook url could not be parsed |
| dpp::webhook::webhook | ( | const snowflake | webhook_id, |
| const std::string & | webhook_token | ||
| ) |
Construct a new webhook object using the webhook ID and the webhook token.
| webhook_id | id taken from a link of an existing webhook |
| webhook_token | token taken from a link of an existing webhook |
|
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 |
Fill in object from json data.
| j | JSON data |
|
inlineconstexprnoexceptinherited |
Get the creation time of this object according to Discord.
| webhook & dpp::webhook::load_image | ( | const std::string & | image_blob, |
| const image_type | type, | ||
| bool | is_base64_encoded = false |
||
| ) |
Base64 encode image data and allocate it to image_data.
| image_blob | Binary image data |
| type | Image type. It can be one of i_gif, i_jpg or i_png. |
| is_base64_encoded | True if the image data is already base64 encoded |
| dpp::length_exception | Image data is larger than the maximum size of 256 kilobytes |
|
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 |
|
protectedvirtual |
Build JSON string from object.
| with_id | Include the ID of the webhook in the json |
|
friend |
| snowflake dpp::webhook::application_id |
The bot/OAuth2 application that created this webhook.
| utility::iconhash dpp::webhook::avatar |
The default avatar of the webhook.
| snowflake dpp::webhook::channel_id |
The channel id this webhook is for.
| snowflake dpp::webhook::guild_id |
The guild id this webhook is for.
|
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.
| std::string dpp::webhook::image_data |
base64 encoded image data if uploading a new image.
| std::string dpp::webhook::name |
The default name of the webhook.
| channel dpp::webhook::source_channel |
The channel that this webhook is following (only for Channel Follower Webhooks).
| guild dpp::webhook::source_guild |
The guild of the channel that this webhook is following (only for Channel Follower Webhooks).
| std::string dpp::webhook::token |
The secure token of the webhook (returned for Incoming Webhooks).
| uint8_t dpp::webhook::type |
Type of the webhook from dpp::webhook_type.
| std::string dpp::webhook::url |
The url used for executing the webhook (returned by the webhooks OAuth2 flow).
| user dpp::webhook::user_obj |
The user this webhook was created by.