From f9c55bf23770a53341fda1648ce4a6624ce77a51 Mon Sep 17 00:00:00 2001 From: Eric <52634785+erics118@users.noreply.github.com> Date: Fri, 20 Oct 2023 19:29:43 -0400 Subject: [PATCH] fix: make embed color optional (#961) --- include/dpp/message.h | 2 +- src/dpp/message.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/dpp/message.h b/include/dpp/message.h index 00e04f7bfc..f877bb2db6 100644 --- a/include/dpp/message.h +++ b/include/dpp/message.h @@ -658,7 +658,7 @@ struct DPP_EXPORT embed { /** Optional: timestamp of embed content */ time_t timestamp; /** Optional: color code of the embed */ - uint32_t color; + std::optional color; /** Optional: footer information */ std::optional footer; /** Optional: image information */ diff --git a/src/dpp/message.cpp b/src/dpp/message.cpp index 810b76f2a2..c3218c8fe3 100644 --- a/src/dpp/message.cpp +++ b/src/dpp/message.cpp @@ -487,7 +487,7 @@ component &component::add_default_value(const snowflake id, const component_defa embed::~embed() = default; -embed::embed() : timestamp(0), color(0) { +embed::embed() : timestamp(0) { } message::message() : managed(0), channel_id(0), guild_id(0), sent(0), edited(0), webhook_id(0), @@ -618,7 +618,9 @@ embed::embed(json* j) : embed() { description = string_not_null(j, "description"); url = string_not_null(j, "url"); timestamp = ts_not_null(j, "timestamp"); - color = int32_not_null(j, "color"); + if (j->contains("color")) { + color = int32_not_null(j, "color"); + } if (j->contains("footer")) { dpp::embed_footer f; json& fj = (*j)["footer"]; @@ -962,7 +964,9 @@ json message::to_json(bool with_id, bool is_interaction_response) const { if (!embed.url.empty()) { e["url"] = embed.url; } - e["color"] = embed.color; + if (embed.color.has_value()) { + e["color"] = embed.color.value(); + } if (embed.footer.has_value()) { e["footer"]["text"] = embed.footer->text; e["footer"]["icon_url"] = embed.footer->icon_url;