From 069c22e9cd37158fa50e3fac67d4d6938d173554 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 24 Nov 2021 20:31:34 -0500 Subject: add fetching private archived threads --- src/discord/discord.cpp | 13 +++++++++++++ src/discord/discord.hpp | 1 + 2 files changed, 14 insertions(+) (limited to 'src/discord') diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index f920099..a90fc50 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -292,6 +292,19 @@ void DiscordClient::GetArchivedPublicThreads(Snowflake channel_id, sigc::slot callback) { + m_http.MakeGET("/channels/" + std::to_string(channel_id) + "/users/@me/threads/archived/private", [this, callback](const http::response_type &r) { + if (CheckCode(r)) { + const auto data = nlohmann::json::parse(r.text).get(); + for (const auto &thread : data.Threads) + m_store.SetChannel(thread.ID, thread); + callback(DiscordError::NONE, data); + } else { + callback(GetCodeFromResponse(r), {}); + } + }); +} + bool DiscordClient::IsThreadJoined(Snowflake thread_id) const { return std::find(m_joined_threads.begin(), m_joined_threads.end(), thread_id) != m_joined_threads.end(); } diff --git a/src/discord/discord.hpp b/src/discord/discord.hpp index 4b9bc82..4010977 100644 --- a/src/discord/discord.hpp +++ b/src/discord/discord.hpp @@ -81,6 +81,7 @@ public: std::vector GetUsersInThread(Snowflake id) const; std::vector GetActiveThreads(Snowflake channel_id) const; void GetArchivedPublicThreads(Snowflake channel_id, sigc::slot callback); + void GetArchivedPrivateThreads(Snowflake channel_id, sigc::slot callback); bool IsThreadJoined(Snowflake thread_id) const; bool HasGuildPermission(Snowflake user_id, Snowflake guild_id, Permission perm) const; -- cgit v1.2.3