From fa749ce1520c0ab21843a439148f27d3eb0b3b26 Mon Sep 17 00:00:00 2001 From: Archie Date: Sun, 14 Jul 2024 11:53:11 +0100 Subject: [PATCH] fix: removed max limit for avatars and banners --- include/dpp/cluster.h | 13 ++++++++----- include/dpp/cluster_coro_calls.h | 13 ++++++++----- include/dpp/cluster_sync_calls.h | 13 ++++++++----- include/dpp/misc-enum.h | 2 +- src/dpp/cluster/user.cpp | 6 ------ 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/include/dpp/cluster.h b/include/dpp/cluster.h index 15629e718d..ab361dd5db 100644 --- a/include/dpp/cluster.h +++ b/include/dpp/cluster.h @@ -3253,15 +3253,18 @@ class DPP_EXPORT cluster { void current_user_get_guilds(command_completion_event_t callback); /** - * @brief Edit current (bot) user + * @brief Edit current (bot) user. + * + * Modify the requester's user account settings. Returns a dpp::user object on success. + * Fires a User Update Gateway event. + * + * @note There appears to be no limit to the image size, however, if your image cannot be processed/uploaded in time, you will receive a malformed http request. * - * Modifies the current member in a guild. Returns the updated guild_member object on success. - * Fires a `Guild Member Update` Gateway event. * @see https://discord.com/developers/docs/resources/user#modify-current-user * @param nickname Nickname to set - * @param avatar_blob Avatar data to upload (NOTE: Very heavily rate limited!) + * @param avatar_blob Avatar data to upload * @param avatar_type Type of image for avatar. It can be one of `i_gif`, `i_jpg` or `i_png`. - * @param banner_blob Banner data to upload (NOTE: Very heavily rate limited!) + * @param banner_blob Banner data to upload * @param banner_type Type of image for Banner. It can be one of `i_gif`, `i_jpg` or `i_png`. * @param callback Function to call when the API call completes. * On success the callback will contain a dpp::user 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(). diff --git a/include/dpp/cluster_coro_calls.h b/include/dpp/cluster_coro_calls.h index 777e67d1f8..bc460605c6 100644 --- a/include/dpp/cluster_coro_calls.h +++ b/include/dpp/cluster_coro_calls.h @@ -2246,16 +2246,19 @@ [[nodiscard]] async co_thread_get(snowflake thread_id); /** - * @brief Edit current (bot) user + * @brief Edit current (bot) user. + * + * Modify the requester's user account settings. Returns a dpp::user object on success. + * Fires a User Update Gateway event. + * + * @note There appears to be no limit to the image size, however, if your image cannot be processed/uploaded in time, you will receive a malformed http request. * - * Modifies the current member in a guild. Returns the updated guild_member object on success. - * Fires a `Guild Member Update` Gateway event. * @see dpp::cluster::current_user_edit * @see https://discord.com/developers/docs/resources/user#modify-current-user * @param nickname Nickname to set - * @param avatar_blob Avatar data to upload (NOTE: Very heavily rate limited!) + * @param avatar_blob Avatar data to upload * @param avatar_type Type of image for avatar. It can be one of `i_gif`, `i_jpg` or `i_png`. - * @param banner_blob Banner data to upload (NOTE: Very heavily rate limited!) + * @param banner_blob Banner data to upload * @param banner_type Type of image for Banner. It can be one of `i_gif`, `i_jpg` or `i_png`. * @return user returned object on completion * @throw dpp::length_exception Image data is larger than the maximum size of 256 kilobytes diff --git a/include/dpp/cluster_sync_calls.h b/include/dpp/cluster_sync_calls.h index 46d38ae429..1086c4926d 100644 --- a/include/dpp/cluster_sync_calls.h +++ b/include/dpp/cluster_sync_calls.h @@ -2765,16 +2765,19 @@ confirmation thread_member_remove_sync(snowflake thread_id, snowflake user_id); thread thread_get_sync(snowflake thread_id); /** - * @brief Edit current (bot) user + * @brief Edit current (bot) user. + * + * Modify the requester's user account settings. Returns a dpp::user object on success. + * Fires a User Update Gateway event. + * + * @note There appears to be no limit to the image size, however, if your image cannot be processed/uploaded in time, you will receive a malformed http request. * - * Modifies the current member in a guild. Returns the updated guild_member object on success. - * Fires a `Guild Member Update` Gateway event. * @see dpp::cluster::current_user_edit * @see https://discord.com/developers/docs/resources/user#modify-current-user * @param nickname Nickname to set - * @param avatar_blob Avatar data to upload (NOTE: Very heavily rate limited!) + * @param avatar_blob Avatar data to upload * @param avatar_type Type of image for avatar. It can be one of `i_gif`, `i_jpg` or `i_png`. - * @param banner_blob Banner data to upload (NOTE: Very heavily rate limited!) + * @param banner_blob Banner data to upload * @param banner_type Type of image for Banner. It can be one of `i_gif`, `i_jpg` or `i_png`. * @return user returned object on completion * @throw dpp::length_exception Image data is larger than the maximum size of 256 kilobytes diff --git a/include/dpp/misc-enum.h b/include/dpp/misc-enum.h index 1a65371dec..8f4f160f5a 100644 --- a/include/dpp/misc-enum.h +++ b/include/dpp/misc-enum.h @@ -28,7 +28,7 @@ namespace dpp { /** * @brief Supported image types for profile pictures and CDN endpoints */ -enum image_type { +enum image_type : uint8_t { /** * @brief image/png */ diff --git a/src/dpp/cluster/user.cpp b/src/dpp/cluster/user.cpp index 71d1415a98..f50732ee57 100644 --- a/src/dpp/cluster/user.cpp +++ b/src/dpp/cluster/user.cpp @@ -38,16 +38,10 @@ void cluster::current_user_edit(const std::string &nickname, const std::string& }; if (!avatar_blob.empty()) { - if (avatar_blob.size() > MAX_EMOJI_SIZE) { - throw dpp::length_exception(err_icon_size, "User icon file exceeds discord limit of 256 kilobytes"); - } j["avatar"] = "data:" + mimetypes.find(avatar_type)->second + ";base64," + base64_encode((unsigned char const*)avatar_blob.data(), static_cast(avatar_blob.length())); } if (!banner_blob.empty()) { - if (banner_blob.size() > MAX_EMOJI_SIZE) { - throw dpp::length_exception(err_icon_size, "User banner file exceeds discord limit of 256 kilobytes"); - } j["banner"] = "data:" + mimetypes.find(banner_type)->second + ";base64," + base64_encode((unsigned char const*)banner_blob.data(), static_cast(banner_blob.length())); }