Skip to content

Commit

Permalink
fix: removed max limit for avatars and banners
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 committed Jul 14, 2024
1 parent 7e7bd2d commit fa749ce
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
13 changes: 8 additions & 5 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
13 changes: 8 additions & 5 deletions include/dpp/cluster_coro_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -2246,16 +2246,19 @@
[[nodiscard]] async<confirmation_callback_t> 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
Expand Down
13 changes: 8 additions & 5 deletions include/dpp/cluster_sync_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/dpp/misc-enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
6 changes: 0 additions & 6 deletions src/dpp/cluster/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>(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<unsigned int>(banner_blob.length()));
}

Expand Down

0 comments on commit fa749ce

Please sign in to comment.