diff --git a/include/dpp/message.h b/include/dpp/message.h index 5f11536f98..22fb5c7146 100644 --- a/include/dpp/message.h +++ b/include/dpp/message.h @@ -766,6 +766,14 @@ struct DPP_EXPORT reaction { ~reaction() = default; }; +/** + * @brief Bitmask flags for a dpp::attachment + */ +enum attachment_flags : uint8_t { + /// this attachment has been edited using the remix feature on mobile + a_is_remix = 1 << 2, +}; + /** * @brief Represents an attachment in a dpp::message */ @@ -794,6 +802,8 @@ struct DPP_EXPORT attachment { double duration_secs; /** base64 encoded bytearray representing a sampled waveform (currently for voice messages) */ std::string waveform; + /** Flags. Made of bits in dpp::attachment_flags */ + uint8_t flags; /** Owning message */ struct message* owner; @@ -824,6 +834,13 @@ struct DPP_EXPORT attachment { * itself has an owning cluster, this method will throw a dpp::logic_exception when called. */ void download(http_completion_event callback) const; + + /** + * @brief Returns true if remixed + * + * @return true if remixed + */ + bool is_remix() const; }; /** @@ -1523,6 +1540,13 @@ struct DPP_EXPORT message : public managed { * @return true if message is a DM */ bool is_dm() const; + + /** + * @brief Returns true if message has remixed attachment + * + * @return true if message has remixed attachment + */ + bool has_remix_attachment() const; }; /** A group of messages */ diff --git a/include/dpp/permissions.h b/include/dpp/permissions.h index 7e027ccf18..f1d1865cdd 100644 --- a/include/dpp/permissions.h +++ b/include/dpp/permissions.h @@ -146,6 +146,25 @@ class DPP_EXPORT permission { return (value & (0 | ... | values)) == (0 | ... | values); } + /** + * @brief Check for permission flags set. It uses the Bitwise AND operator + * @tparam T one or more uint64_t permission bits + * @param values The permissions (from dpp::permissions) to check for + * + * **Example:** + * + * ```cpp + * bool is_mod = permission.has_any(dpp::p_administrator, dpp::p_ban_members); + * // Returns true if the permission bitmask contains p_administrator or p_ban_members + * ``` + * + * @return bool True if it has any the given permissions + */ + template + constexpr bool has_any(T... values) const noexcept { + return (value & (0 | ... | values)) != 0; + } + /** * @brief Add a permission with the Bitwise OR operation * @tparam T one or more uint64_t permission bits diff --git a/src/dpp/discordclient.cpp b/src/dpp/discordclient.cpp index f0742b5dd3..77399eaf99 100644 --- a/src/dpp/discordclient.cpp +++ b/src/dpp/discordclient.cpp @@ -645,7 +645,7 @@ void discord_client::disconnect_voice_internal(snowflake guild_id, bool emit_jso std::unique_lock lock(voice_mutex); auto v = connecting_voice_channels.find(guild_id); if (v != connecting_voice_channels.end()) { - log(ll_debug, "Disconnecting voice, guild: {}" + std::to_string(guild_id)); + log(ll_debug, "Disconnecting voice, guild: " + std::to_string(guild_id)); if (emit_json) { queue_message(jsonobj_to_string(json({ { "op", 4 }, diff --git a/src/dpp/message.cpp b/src/dpp/message.cpp index 3f4331ad05..ec6a36fa1b 100644 --- a/src/dpp/message.cpp +++ b/src/dpp/message.cpp @@ -18,6 +18,7 @@ * limitations under the License. * ************************************************************************************/ +#include #include #include #include @@ -768,6 +769,7 @@ attachment::attachment(struct message* o) , width(0) , height(0) , ephemeral(false) + , flags(0) , owner(o) { } @@ -785,6 +787,7 @@ attachment::attachment(struct message* o, json *j) : attachment(o) { this->ephemeral = bool_not_null(j, "ephemeral"); this->duration_secs = double_not_null(j, "duration_secs"); this->waveform = string_not_null(j, "waveform"); + this->flags = int8_not_null(j, "flags"); } void attachment::download(http_completion_event callback) const { @@ -797,6 +800,10 @@ void attachment::download(http_completion_event callback) const { } } +bool attachment::is_remix() const { + return flags & a_is_remix; +} + std::string message::build_json(bool with_id, bool is_interaction_response) const { /* This is the basics. once it works, expand on it. */ json j({ @@ -1117,6 +1124,15 @@ message& message::fill_from_json(json* d, cache_policy_t cp) { return *this; } +bool message::has_remix_attachment() const { + return std::any_of( + attachments.begin(), + attachments.end(), + [](const auto& a) -> bool { + return a.is_remix(); + }); +} + sticker::sticker() : managed(0), pack_id(0), type(st_standard), format_type(sf_png), available(true), guild_id(0), sort_value(0) { }