Skip to content

Commit

Permalink
Merge pull request #413 from Commandserver/dev
Browse files Browse the repository at this point in the history
breaking: removed reason parameter from cluster::guild_ban_add method
  • Loading branch information
braindigitalis authored Jun 11, 2022
2 parents 8b60c25 + c7bec36 commit fccb729
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
9 changes: 4 additions & 5 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -2485,19 +2485,18 @@ class DPP_EXPORT cluster {

/**
* @brief Add guild ban
*
*
* Create a guild ban, and optionally delete previous messages sent by the banned user.
* Requires the `BAN_MEMBERS` permission. Fires a `Guild Ban Add` Gateway event.
* @see https://discord.com/developers/docs/resources/guild#create-guild-ban
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to add ban to
* @param user_id User ID to ban
* @param delete_message_days How many days of their user's messages to also delete
* @param reason Reason for ban
* @param delete_message_days How many days of their user's messages to also delete (0-7). Defaults to 0
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::ban 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().
* On success the callback will contain a dpp::confirmation 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 guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_days, const std::string &reason, command_completion_event_t callback = utility::log_error());
void guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_days = 0, command_completion_event_t callback = utility::log_error());

/**
* @brief Delete guild ban
Expand Down
7 changes: 3 additions & 4 deletions include/dpp/cluster_sync_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,23 +717,22 @@ auditlog guild_auditlog_get_sync(snowflake guild_id);

/**
* @brief Add guild ban
*
*
* Create a guild ban, and optionally delete previous messages sent by the banned user.
* Requires the `BAN_MEMBERS` permission. Fires a `Guild Ban Add` Gateway event.
* @see dpp::cluster::guild_ban_add
* @see https://discord.com/developers/docs/resources/guild#create-guild-ban
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to add ban to
* @param user_id User ID to ban
* @param delete_message_days How many days of their user's messages to also delete
* @param reason Reason for ban
* @param delete_message_days How many days of their user's messages to also delete (0-7). Defaults to 0
* @return confirmation returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
confirmation guild_ban_add_sync(snowflake guild_id, snowflake user_id, uint32_t delete_message_days, const std::string &reason);
confirmation guild_ban_add_sync(snowflake guild_id, snowflake user_id, uint32_t delete_message_days = 0);

/**
* @brief Delete guild ban
Expand Down
6 changes: 2 additions & 4 deletions src/dpp/cluster/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ void cluster::guild_auditlog_get(snowflake guild_id, command_completion_event_t
}


void cluster::guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_days, const std::string &reason, command_completion_event_t callback) {
void cluster::guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_days, command_completion_event_t callback) {
json j;
if (delete_message_days > 7)
delete_message_days = 7;
if (!reason.empty())
j["reason"] = reason;
if (delete_message_days)
j["delete_message_days"] = delete_message_days;
rest_request<confirmation>(this, API_PATH "/guilds", std::to_string(guild_id), "bans/" + std::to_string(user_id), m_put, j.dump(), callback);
Expand Down Expand Up @@ -123,7 +121,7 @@ void cluster::guild_get_prune_counts(snowflake guild_id, const struct prune& pru
}

void cluster::guild_begin_prune(snowflake guild_id, const struct prune& pruneinfo, command_completion_event_t callback) {
rest_request<prune>(this, API_PATH "/guilds", std::to_string(guild_id), "prune", m_get, pruneinfo.build_json(true), callback);
rest_request<prune>(this, API_PATH "/guilds", std::to_string(guild_id), "prune", m_post, pruneinfo.build_json(true), callback);
}


Expand Down
4 changes: 2 additions & 2 deletions src/dpp/cluster_sync_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ auditlog cluster::guild_auditlog_get_sync(snowflake guild_id) {
return dpp::sync<auditlog>(this, &cluster::guild_auditlog_get, guild_id);
}

confirmation cluster::guild_ban_add_sync(snowflake guild_id, snowflake user_id, uint32_t delete_message_days, const std::string &reason) {
return dpp::sync<confirmation>(this, &cluster::guild_ban_add, guild_id, user_id, delete_message_days, reason);
confirmation cluster::guild_ban_add_sync(snowflake guild_id, snowflake user_id, uint32_t delete_message_days) {
return dpp::sync<confirmation>(this, &cluster::guild_ban_add, guild_id, user_id, delete_message_days);
}

confirmation cluster::guild_ban_delete_sync(snowflake guild_id, snowflake user_id) {
Expand Down

0 comments on commit fccb729

Please sign in to comment.