Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/dpp/webhook.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,19 @@ class DPP_EXPORT webhook : public managed, public json_interface<webhook> {
/**
* @brief The default avatar of the webhook.
*
* @note This value will not have any effect when `avatar_url` is set, they are mutually exclusive.
* @note This may be empty.
*/
utility::iconhash avatar;

/**
* @brief Avatar URL to use instead of the default if it is set.
*
* @note This will override `avatar` if it is set, they are mutually exclusive.
* @note This may be empty.
*/
std::string avatar_url;

/**
* @brief The secure token of the webhook (returned for Incoming Webhooks).
*
Expand Down
6 changes: 4 additions & 2 deletions src/dpp/cluster/webhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ void cluster::execute_webhook(const class webhook &wh, const struct message& m,
{"with_components", true},
});
std::string body;
if (!thread_name.empty() || !wh.avatar.to_string().empty() || !wh.name.empty()) { // only use json::parse if thread_name is set
if (!thread_name.empty() || !wh.avatar.to_string().empty() || !wh.avatar_url.empty() || !wh.name.empty()) { // only use json::parse if a value needs to be changed
json j = m.to_json(false);
if (!thread_name.empty()) {
j["thread_name"] = thread_name;
}
if (!wh.avatar.to_string().empty()) {
if (!wh.avatar_url.empty()) {
j["avatar_url"] = wh.avatar_url;
} else if (!wh.avatar.to_string().empty()) {
j["avatar_url"] = wh.avatar.to_string();
}
if (!wh.name.empty()) {
Expand Down
Loading