From d0f4e3b075d584e20ca90a0a5eed8cf48a5e9932 Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Mon, 9 Oct 2023 09:22:48 +0000 Subject: [PATCH] fix: run coro and sync generator to make coro and sync thread_get --- include/dpp/cluster_coro_calls.h | 10 ++++++++++ include/dpp/cluster_sync_calls.h | 13 +++++++++++++ src/dpp/cluster_coro_calls.cpp | 4 ++++ src/dpp/cluster_sync_calls.cpp | 4 ++++ 4 files changed, 31 insertions(+) diff --git a/include/dpp/cluster_coro_calls.h b/include/dpp/cluster_coro_calls.h index a6d0604eec..b98d914642 100644 --- a/include/dpp/cluster_coro_calls.h +++ b/include/dpp/cluster_coro_calls.h @@ -2061,6 +2061,16 @@ */ [[nodiscard]] async co_thread_member_remove(snowflake thread_id, snowflake user_id); +/** + * @brief Get the thread specified by thread_id. This uses the same call as dpp::cluster::channel_get but returns a thread object. + * @see dpp::cluster::thread_get + * @see https://discord.com/developers/docs/resources/channel#get-channel + * @param thread_id The id of the thread to obtain. + * @return thread returned object on completion + * \memberof dpp::cluster + */ +[[nodiscard]] async co_thread_get(snowflake thread_id); + /** * @brief Edit current (bot) user * diff --git a/include/dpp/cluster_sync_calls.h b/include/dpp/cluster_sync_calls.h index 7ae7d3f54a..0b7ff5069f 100644 --- a/include/dpp/cluster_sync_calls.h +++ b/include/dpp/cluster_sync_calls.h @@ -2535,6 +2535,19 @@ confirmation thread_member_add_sync(snowflake thread_id, snowflake user_id); */ confirmation thread_member_remove_sync(snowflake thread_id, snowflake user_id); +/** + * @brief Get the thread specified by thread_id. This uses the same call as dpp::cluster::channel_get but returns a thread object. + * @see dpp::cluster::thread_get + * @see https://discord.com/developers/docs/resources/channel#get-channel + * @param thread_id The id of the thread to obtain. + * @return thread 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. + */ +thread thread_get_sync(snowflake thread_id); + /** * @brief Edit current (bot) user * diff --git a/src/dpp/cluster_coro_calls.cpp b/src/dpp/cluster_coro_calls.cpp index 5dbdf9ef00..32edde0e17 100644 --- a/src/dpp/cluster_coro_calls.cpp +++ b/src/dpp/cluster_coro_calls.cpp @@ -687,6 +687,10 @@ async cluster::co_thread_member_remove(snowflake thread return async{ this, static_cast(&cluster::thread_member_remove), thread_id, user_id }; } +async cluster::co_thread_get(snowflake thread_id) { + return async{ this, static_cast(&cluster::thread_get), thread_id }; +} + async cluster::co_current_user_edit(const std::string &nickname, const std::string& image_blob, const image_type type) { return async{ this, static_cast(&cluster::current_user_edit), nickname, image_blob, type }; } diff --git a/src/dpp/cluster_sync_calls.cpp b/src/dpp/cluster_sync_calls.cpp index 1e45f6d736..0cd703d095 100644 --- a/src/dpp/cluster_sync_calls.cpp +++ b/src/dpp/cluster_sync_calls.cpp @@ -685,6 +685,10 @@ confirmation cluster::thread_member_remove_sync(snowflake thread_id, snowflake u return dpp::sync(this, static_cast(&cluster::thread_member_remove), thread_id, user_id); } +thread cluster::thread_get_sync(snowflake thread_id) { + return dpp::sync(this, static_cast(&cluster::thread_get), thread_id); +} + user cluster::current_user_edit_sync(const std::string &nickname, const std::string& image_blob, const image_type type) { return dpp::sync(this, static_cast(&cluster::current_user_edit), nickname, image_blob, type); }