Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dpp::cluster::guild_member_timeout_remove and its sync/coro versions #1067

Merged
merged 6 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,19 @@ class DPP_EXPORT cluster {
*/
void guild_member_timeout(snowflake guild_id, snowflake user_id, time_t communication_disabled_until, command_completion_event_t callback = utility::log_error());

/**
* @brief Remove the timeout of a guild member.
* A shortcut for guild_member_timeout(guild_id, user_id, 0, callback)
* Fires a `Guild Member Update` Gateway event.
* @see https://discord.com/developers/docs/resources/guild#modify-guild-member
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to remove the member timeout from
* @param user_id User ID to remove the timeout for
* @param callback Function to call when the API call completes.
* 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_member_timeout_remove(snowflake guild_id, snowflake user_id, command_completion_event_t callback = utility::log_error());

/**
* @brief Add guild ban
*
Expand Down
14 changes: 14 additions & 0 deletions include/dpp/cluster_coro_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,20 @@
*/
[[nodiscard]] async<confirmation_callback_t> co_guild_member_timeout(snowflake guild_id, snowflake user_id, time_t communication_disabled_until);

/**
* @brief Remove the timeout of a guild member.
* A shortcut for guild_member_timeout(guild_id, user_id, 0, callback)
* Fires a `Guild Member Update` Gateway event.
* @see dpp::cluster::guild_member_timeout_remove
* @see https://discord.com/developers/docs/resources/guild#modify-guild-member
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to remove the member timeout from
* @param user_id User ID to remove the timeout for
* @return confirmation returned object on completion
* \memberof dpp::cluster
*/
[[nodiscard]] async<confirmation_callback_t> co_guild_member_timeout_remove(snowflake guild_id, snowflake user_id);

/**
* @brief Remove role from guild member
*
Expand Down
17 changes: 17 additions & 0 deletions include/dpp/cluster_sync_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,23 @@ confirmation guild_member_kick_sync(snowflake guild_id, snowflake user_id);
*/
confirmation guild_member_timeout_sync(snowflake guild_id, snowflake user_id, time_t communication_disabled_until);

/**
* @brief Remove the timeout of a guild member.
* A shortcut for guild_member_timeout(guild_id, user_id, 0, callback)
* Fires a `Guild Member Update` Gateway event.
* @see dpp::cluster::guild_member_timeout_remove
* @see https://discord.com/developers/docs/resources/guild#modify-guild-member
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to remove the member timeout from
* @param user_id User ID to remove the timeout for
* @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_member_timeout_remove_sync(snowflake guild_id, snowflake user_id);

/**
* @brief Remove role from guild member
*
Expand Down
6 changes: 6 additions & 0 deletions src/dpp/cluster/guild_member.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ void cluster::guild_member_timeout(snowflake guild_id, snowflake user_id, time_t
rest_request<confirmation>(this, API_PATH "/guilds", std::to_string(guild_id), "members/" + std::to_string(user_id), m_patch, j.dump(), callback);
}

void cluster::guild_member_timeout_remove(snowflake guild_id, snowflake user_id, command_completion_event_t callback) {
json j;
j["communication_disabled_until"] = json::value_t::null;
rest_request<confirmation>(this, API_PATH "/guilds", std::to_string(guild_id), "members/" + std::to_string(user_id), m_patch, j.dump(), callback);
}


void cluster::guild_member_delete_role(snowflake guild_id, snowflake user_id, snowflake role_id, command_completion_event_t callback) {
rest_request<confirmation>(this, API_PATH "/guilds", std::to_string(guild_id), "members/" + std::to_string(user_id) + "/roles/" + std::to_string(role_id), m_delete, "", callback);
Expand Down
4 changes: 4 additions & 0 deletions src/dpp/cluster_coro_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ async<confirmation_callback_t> cluster::co_guild_member_timeout(snowflake guild_
return async{ this, static_cast<void (cluster::*)(snowflake, snowflake, time_t, command_completion_event_t)>(&cluster::guild_member_timeout), guild_id, user_id, communication_disabled_until };
}

async<confirmation_callback_t> cluster::co_guild_member_timeout_remove(snowflake guild_id, snowflake user_id) {
return async{ this, static_cast<void (cluster::*)(snowflake, snowflake, command_completion_event_t)>(&cluster::guild_member_timeout_remove), guild_id, user_id };
}

async<confirmation_callback_t> cluster::co_guild_member_delete_role(snowflake guild_id, snowflake user_id, snowflake role_id) {
return async{ this, static_cast<void (cluster::*)(snowflake, snowflake, snowflake, command_completion_event_t)>(&cluster::guild_member_delete_role), guild_id, user_id, role_id };
}
Expand Down
4 changes: 4 additions & 0 deletions src/dpp/cluster_sync_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ confirmation cluster::guild_member_timeout_sync(snowflake guild_id, snowflake us
return dpp::sync<confirmation>(this, static_cast<void (cluster::*)(snowflake, snowflake, time_t, command_completion_event_t)>(&cluster::guild_member_timeout), guild_id, user_id, communication_disabled_until);
}

confirmation cluster::guild_member_timeout_remove_sync(snowflake guild_id, snowflake user_id) {
return dpp::sync<confirmation>(this, static_cast<void (cluster::*)(snowflake, snowflake, command_completion_event_t)>(&cluster::guild_member_timeout_remove), guild_id, user_id);
}

confirmation cluster::guild_member_delete_role_sync(snowflake guild_id, snowflake user_id, snowflake role_id) {
return dpp::sync<confirmation>(this, static_cast<void (cluster::*)(snowflake, snowflake, snowflake, command_completion_event_t)>(&cluster::guild_member_delete_role), guild_id, user_id, role_id);
}
Expand Down