diff --git a/include/dpp/cluster.h b/include/dpp/cluster.h index eb275d96bf..45b79dd0ea 100644 --- a/include/dpp/cluster.h +++ b/include/dpp/cluster.h @@ -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 * diff --git a/include/dpp/cluster_coro_calls.h b/include/dpp/cluster_coro_calls.h index 21431c9dfa..5ba256c101 100644 --- a/include/dpp/cluster_coro_calls.h +++ b/include/dpp/cluster_coro_calls.h @@ -1236,6 +1236,20 @@ */ [[nodiscard]] async co_guild_member_timeout(snowflake guild_id, snowflake user_id, time_t communication_disabled_until); +/** + * @brief Remove the timeout of a guild member + * Shortcut to co_guild_member_timeout(guild_id, user_id, 0) + * Fires a `Guild Member Update` Gateway event. + * @see dpp::cluster::guild_member_timeout + * @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 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 co_guild_member_timeout_remove(snowflake guild_id, snowflake user_id); + /** * @brief Remove role from guild member * diff --git a/include/dpp/cluster_sync_calls.h b/include/dpp/cluster_sync_calls.h index 140b9ba5a1..2ecdbbc73d 100644 --- a/include/dpp/cluster_sync_calls.h +++ b/include/dpp/cluster_sync_calls.h @@ -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 + * Shortcut for guild_member_timeout_sync(guild_id, user_id, 0) + * Fires a `Guild Member Update` Gateway event. + * @see dpp::cluster::guild_member_timeout + * @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 timeout from the member in + * @param user_id User ID to set 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 * diff --git a/src/dpp/cluster/guild_member.cpp b/src/dpp/cluster/guild_member.cpp index e851e9c7ad..2533895203 100644 --- a/src/dpp/cluster/guild_member.cpp +++ b/src/dpp/cluster/guild_member.cpp @@ -96,6 +96,10 @@ void cluster::guild_member_timeout(snowflake guild_id, snowflake user_id, time_t rest_request(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) { + guild_member_timeout(guild_id, user_id, 0, callback); +} + void cluster::guild_member_delete_role(snowflake guild_id, snowflake user_id, snowflake role_id, command_completion_event_t callback) { rest_request(this, API_PATH "/guilds", std::to_string(guild_id), "members/" + std::to_string(user_id) + "/roles/" + std::to_string(role_id), m_delete, "", callback); diff --git a/src/dpp/cluster_coro_calls.cpp b/src/dpp/cluster_coro_calls.cpp index 28f0eca82a..20e9119cc3 100644 --- a/src/dpp/cluster_coro_calls.cpp +++ b/src/dpp/cluster_coro_calls.cpp @@ -411,6 +411,10 @@ async cluster::co_guild_member_timeout(snowflake guild_ return async{ this, static_cast(&cluster::guild_member_timeout), guild_id, user_id, communication_disabled_until }; } +async cluster::co_guild_member_timeout(snowflake guild_id, snowflake user_id) { + return co_guild_member_timeout_remove(guild_id, user_id, 0); +} + async cluster::co_guild_member_delete_role(snowflake guild_id, snowflake user_id, snowflake role_id) { return async{ this, static_cast(&cluster::guild_member_delete_role), guild_id, user_id, role_id }; } diff --git a/src/dpp/cluster_sync_calls.cpp b/src/dpp/cluster_sync_calls.cpp index 876c0d0327..cdc885a863 100644 --- a/src/dpp/cluster_sync_calls.cpp +++ b/src/dpp/cluster_sync_calls.cpp @@ -409,6 +409,11 @@ confirmation cluster::guild_member_timeout_sync(snowflake guild_id, snowflake us return dpp::sync(this, static_cast(&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 guild_member_timeout_sync(guild_id, user_id, 0); +} + + confirmation cluster::guild_member_delete_role_sync(snowflake guild_id, snowflake user_id, snowflake role_id) { return dpp::sync(this, static_cast(&cluster::guild_member_delete_role), guild_id, user_id, role_id); }