Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
AA1999 authored Mar 23, 2024
2 parents 24e7ef3 + 4f83914 commit 69b0da4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
9 changes: 9 additions & 0 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,15 @@ class DPP_EXPORT cluster {
*/
void message_edit(const struct message &m, command_completion_event_t callback = utility::log_error());

/**
* @brief Edit the flags of a message on a channel. The callback function is called when the message has been edited
*
* @param m Message to edit the flags of
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::message object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
*/
void message_edit_flags(const struct message &m, command_completion_event_t callback = utility::log_error());

/**
* @brief Add a reaction to a message. The reaction string must be either an `emojiname:id` or a unicode character.
*
Expand Down
8 changes: 8 additions & 0 deletions include/dpp/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,14 @@ struct DPP_EXPORT message : public managed, json_interface<message> {
*/
bool suppress_embeds() const;

/**
* @brief Set whether embeds should be suppressed
*
* @param suppress whether embeds should be suppressed
* @return message& reference to self
*/
message& suppress_embeds(bool suppress);

/**
* @brief True if source message was deleted
*
Expand Down
10 changes: 10 additions & 0 deletions src/dpp/cluster/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ void cluster::message_edit(const message &m, command_completion_event_t callback
}, m.file_data);
}

void cluster::message_edit_flags(const message &m, command_completion_event_t callback) {
this->post_rest_multipart(API_PATH "/channels", std::to_string(m.channel_id), "messages/" + std::to_string(m.id), m_patch, nlohmann::json{
{"flags", m.flags},
}.dump(), [this, callback](json &j, const http_request_completion_t& http) {
if (callback) {
callback(confirmation_callback_t(this, message(this).fill_from_json(&j), http));
}
}, m.file_data);
}


void cluster::message_get(snowflake message_id, snowflake channel_id, command_completion_event_t callback) {
rest_request<message>(this, API_PATH "/channels", std::to_string(channel_id), "messages/" + std::to_string(message_id), m_get, "", callback);
Expand Down
13 changes: 11 additions & 2 deletions src/dpp/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void to_json(json& j, const component& cp) {
o["type"] = "channel";
} else if (v.type == dpp::cdt_user) {
o["type"] = "user";
}
}
j["default_values"].push_back(o);
}
}
Expand Down Expand Up @@ -844,7 +844,7 @@ reaction::reaction(json* j) {
}
}

attachment::attachment(struct message* o)
attachment::attachment(struct message* o)
: id(0)
, size(0)
, width(0)
Expand Down Expand Up @@ -1071,6 +1071,15 @@ bool message::suppress_embeds() const {
return flags & m_suppress_embeds;
}

message& message::suppress_embeds(bool suppress) {
if (suppress) {
flags |= m_suppress_embeds;
} else {
flags &= ~m_suppress_embeds;
}
return *this;
}

bool message::is_source_message_deleted() const {
return flags & m_source_message_deleted;
}
Expand Down

0 comments on commit 69b0da4

Please sign in to comment.