Skip to content

Commit

Permalink
fix: make embed color optional
Browse files Browse the repository at this point in the history
  • Loading branch information
erics118 committed Oct 20, 2023
1 parent 458ebb4 commit b6854d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/dpp/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t> color;
/** Optional: footer information */
std::optional<embed_footer> footer;
/** Optional: image information */
Expand Down
6 changes: 4 additions & 2 deletions src/dpp/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -962,7 +962,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;
Expand Down

0 comments on commit b6854d3

Please sign in to comment.