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

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 std::string &webhook_url)
 Construct a new webhook object using the Webhook URL provided by Discord. 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 ()
 Destroy the webhook object. More...
 
webhookfill_from_json (nlohmann::json *j)
 Fill in object from json data. More...
 
std::string build_json (bool with_id=false) const
 Build JSON string from object. More...
 
webhookload_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...
 
double get_creation_time () const
 Get the creation time of this object according to Discord. More...
 

Public Attributes

uint8_t type
 the type of the webhook More...
 
snowflake guild_id
 Optional: the guild id this webhook is for. More...
 
snowflake channel_id
 the channel id this webhook is for More...
 
snowflake user_id
 Optional: the user this webhook was created by (not returned when getting a webhook with its token) More...
 
std::string name
 the default name of the webhook (may be empty) More...
 
std::string avatar
 the default avatar of the webhook (may be empty) More...
 
std::string token
 Optional: the secure token of the webhook (returned for Incoming Webhooks) More...
 
snowflake application_id
 the bot/OAuth2 application that created this webhook (may be empty) More...
 
std::string * image_data
 base64 encoded image data if uploading a new image 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...
 

Detailed Description

Represents a discord webhook.

Constructor & Destructor Documentation

◆ webhook() [1/3]

dpp::webhook::webhook ( )

Construct a new webhook object.

◆ webhook() [2/3]

dpp::webhook::webhook ( const std::string &  webhook_url)

Construct a new webhook object using the Webhook URL provided by Discord.

Parameters
webhook_urla fully qualified web address of an existing webhook

◆ webhook() [3/3]

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.

Parameters
webhook_idid taken from a link of an existing webhook
webhook_tokentoken taken from a link of an existing webhook

◆ ~webhook()

dpp::webhook::~webhook ( )

Destroy the webhook object.

Member Function Documentation

◆ build_json()

std::string dpp::webhook::build_json ( bool  with_id = false) const

Build JSON string from object.

Parameters
with_idInclude the ID of the webhook in the json
Returns
std::string JSON encoded object

◆ fill_from_json()

webhook & dpp::webhook::fill_from_json ( nlohmann::json j)

Fill in object from json data.

Parameters
jJSON data
Returns
webhook& Reference to self

◆ get_creation_time()

double dpp::managed::get_creation_time ( ) const
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.

◆ load_image()

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.

Parameters
image_blobBinary image data
typeImage type
is_base64_encodedTrue if the image data is already base64 encoded
Returns
webhook& Reference to self
Exceptions
dpp::exceptionImage data is larger than the maximum size of 256 kilobytes

Member Data Documentation

◆ application_id

snowflake dpp::webhook::application_id

the bot/OAuth2 application that created this webhook (may be empty)

◆ avatar

std::string dpp::webhook::avatar

the default avatar of the webhook (may be empty)

◆ channel_id

snowflake dpp::webhook::channel_id

the channel id this webhook is for

◆ guild_id

snowflake dpp::webhook::guild_id

Optional: the guild id this webhook is for.

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

◆ image_data

std::string* dpp::webhook::image_data

base64 encoded image data if uploading a new image

◆ name

std::string dpp::webhook::name

the default name of the webhook (may be empty)

◆ token

std::string dpp::webhook::token

Optional: the secure token of the webhook (returned for Incoming Webhooks)

◆ type

uint8_t dpp::webhook::type

the type of the webhook

◆ user_id

snowflake dpp::webhook::user_id

Optional: the user this webhook was created by (not returned when getting a webhook with its token)

D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ 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