39 static constexpr auto parseValue =
40 createObject(
"attachments", &value_type::attachments,
"components", &value_type::components,
"allowedMentions", &value_type::allowedMentions,
"stickerIds",
41 &value_type::stickerIds,
"embeds", &value_type::embeds,
"files", &value_type::files,
"content", &value_type::content,
"flags", &value_type::flags);
46 static constexpr auto parseValue = createObject(
"autoArchiveDuration", &value_type::autoArchiveDuration,
"rateLimitPerUser", &value_type::rateLimitPerUser,
"threadName",
47 &value_type::threadName,
"messageId", &value_type::messageId,
"channelId", &value_type::channelId,
"reason", &value_type::reason);
50 template<>
struct core<
discord_core_api::start_thread_without_message_data> {
52 static constexpr auto parseValue =
53 createObject(
"autoArchiveDuration", &value_type::autoArchiveDuration,
"type", &value_type::type,
"rateLimitPerUser", &value_type::rateLimitPerUser,
"threadName",
54 &value_type::threadName,
"channelId", &value_type::channelId,
"reason", &value_type::reason,
"invitable", &value_type::invitable);
57 template<>
struct core<
discord_core_api::start_thread_in_forum_channel_data> {
59 static constexpr auto parseValue = createObject(
"autoArchiveDuration", &value_type::autoArchiveDuration,
"message", &value_type::message,
"rateLimitPerUser",
60 &value_type::rateLimitPerUser,
"channelId", &value_type::channelId,
"reason", &value_type::reason,
"name", &value_type::name);
67 void threads::initialize(discord_core_internal::https_client* client) {
68 threads::httpsClient = client;
72 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Thread_With_Message };
73 co_await newThreadAwaitable<thread_data>();
74 workload.workloadClass = discord_core_internal::https_workload_class::Post;
75 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/messages/" + dataPackage.
messageId +
"/threads";
76 parser.serializeJson<
true>(dataPackage, workload.content);
77 workload.callStack =
"threads::startThreadWithMessageAsync()";
78 if (dataPackage.
reason !=
"") {
79 workload.headersToInsert[
"x-audit-log-reason"] = dataPackage.
reason;
82 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
87 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Thread_Without_Message };
88 co_await newThreadAwaitable<thread_data>();
89 workload.workloadClass = discord_core_internal::https_workload_class::Post;
90 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/threads";
91 parser.serializeJson<
true>(dataPackage, workload.content);
92 workload.callStack =
"threads::startThreadWithoutMessageAsync()";
93 if (dataPackage.
reason !=
"") {
94 workload.headersToInsert[
"x-audit-log-reason"] = dataPackage.
reason;
97 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
102 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Thread_In_Forum_Channel };
103 co_await newThreadAwaitable<thread_data>();
104 workload.workloadClass = discord_core_internal::https_workload_class::Post;
105 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/threads";
106 parser.serializeJson<
true>(dataPackage, workload.content);
107 workload.callStack =
"threads::startThreadInForumChannelAsync()";
108 if (dataPackage.
reason !=
"") {
109 workload.headersToInsert[
"x-audit-log-reason"] = dataPackage.
reason;
112 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
113 co_return returnData;
117 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Put_Self_In_Thread };
118 co_await newThreadAwaitable<void>();
119 workload.workloadClass = discord_core_internal::https_workload_class::Put;
120 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/thread-members/@me";
121 workload.callStack =
"threads::joinThreadAsync()";
122 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload));
127 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Put_Thread_Member };
128 co_await newThreadAwaitable<void>();
129 workload.workloadClass = discord_core_internal::https_workload_class::Put;
130 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/thread-members/" + dataPackage.
userId;
131 workload.callStack =
"threads::addThreadMemberAsync()";
132 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload));
137 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Self_From_Thread };
138 co_await newThreadAwaitable<void>();
139 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
140 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/thread-members/@me";
141 workload.callStack =
"threads::leaveThreadAsync()";
142 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload));
147 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Thread_Member };
148 co_await newThreadAwaitable<void>();
149 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
150 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/thread-members/" + dataPackage.
userId;
151 workload.callStack =
"threads::removeThreadMemberAsync()";
152 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload));
157 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Thread_Member };
158 co_await newThreadAwaitable<thread_member_data>();
159 workload.workloadClass = discord_core_internal::https_workload_class::Get;
160 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/thread-members/" + dataPackage.
userId;
161 workload.callStack =
"threads::getThreadMemberAsync()";
163 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
164 co_return returnData;
168 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Thread_Members };
169 co_await newThreadAwaitable<jsonifier::vector<thread_member_data>>();
170 workload.workloadClass = discord_core_internal::https_workload_class::Get;
171 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/thread-members";
172 workload.callStack =
"threads::getThreadMembersAsync()";
173 jsonifier::vector<thread_member_data> returnData{};
174 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
175 co_return returnData;
179 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Active_Threads };
180 co_await newThreadAwaitable<active_threads_data>();
181 workload.workloadClass = discord_core_internal::https_workload_class::Get;
182 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/threads/active";
183 workload.callStack =
"threads::getActiveThreadsAsync()";
185 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
186 co_return returnData;
190 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Public_Archived_Threads };
191 co_await newThreadAwaitable<archived_threads_data>();
192 workload.workloadClass = discord_core_internal::https_workload_class::Get;
193 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/threads/archived/public";
194 if (dataPackage.
before !=
"") {
195 workload.relativePath +=
"?before=" + dataPackage.
before;
196 if (dataPackage.
limit != 0) {
197 workload.relativePath +=
"&limit=" + jsonifier::toString(dataPackage.
limit);
199 }
else if (dataPackage.
limit != 0) {
200 workload.relativePath +=
"?limit=" + jsonifier::toString(dataPackage.
limit);
202 workload.callStack =
"threads::getPublicArchivedThreadsAsync()";
204 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
205 co_return returnData;
209 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Private_Archived_Threads };
210 co_await newThreadAwaitable<archived_threads_data>();
211 workload.workloadClass = discord_core_internal::https_workload_class::Get;
212 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/threads/archived/protected";
213 if (dataPackage.
before !=
"") {
214 workload.relativePath +=
"?before=" + dataPackage.
before;
215 if (dataPackage.
limit != 0) {
216 workload.relativePath +=
"&limit=" + jsonifier::toString(dataPackage.
limit);
218 }
else if (dataPackage.
limit != 0) {
219 workload.relativePath +=
"?limit=" + jsonifier::toString(dataPackage.
limit);
221 workload.callStack =
"threads::getPrivateArchivedThreadsAsync()";
223 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
224 co_return returnData;
228 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Joined_Private_Archived_Threads };
229 co_await newThreadAwaitable<archived_threads_data>();
230 workload.workloadClass = discord_core_internal::https_workload_class::Get;
231 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/users/@me/threads/archived/protected";
232 if (dataPackage.
before !=
"") {
233 workload.relativePath +=
"?before=" + dataPackage.
before;
234 if (dataPackage.
limit != 0) {
235 workload.relativePath +=
"&limit=" + jsonifier::toString(dataPackage.
limit);
237 }
else if (dataPackage.
limit != 0) {
238 workload.relativePath +=
"?limit=" + jsonifier::toString(dataPackage.
limit);
240 workload.callStack =
"threads::getJoinedPrivateArchivedThreadsAsync()";
242 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
243 co_return returnData;
247 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Guild_Active_Threads };
248 co_await newThreadAwaitable<active_threads_data>();
249 workload.workloadClass = discord_core_internal::https_workload_class::Get;
250 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/threads/active";
251 workload.callStack =
"threads::listActiveThreadsAsync()";
253 threads::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
254 co_return returnData;
A co_routine - representing a potentially asynchronous operation/function.
For sending Https requests.
Represents a single thread_data.
Data for a single member of a thread_data.
static co_routine< archived_threads_data > getPublicArchivedThreadsAsync(const get_public_archived_threads_data dataPackage)
Collects a list of public archived threads from a given channel.
static co_routine< void > leaveThreadAsync(const leave_thread_data dataPackage)
Leaves a thread_data.
static co_routine< void > joinThreadAsync(const join_thread_data dataPackage)
Joins a thread_data.
static co_routine< thread_data > startThreadInForumChannelAsync(const start_thread_in_forum_channel_data dataPackage)
Starts a thread_data, in a forum channel.
static co_routine< void > addThreadMemberAsync(const add_thread_member_data dataPackage)
Adds a new user_data to a chosen thread_data.
static co_routine< thread_member_data > getThreadMemberAsync(const get_thread_member_data dataPackage)
Collects a thread_member if they exist.
static co_routine< active_threads_data > getActiveThreadsAsync(const get_active_threads_data dataPackage)
Collects a list of threads from a given channel.
static co_routine< active_threads_data > getActiveGuildThreadsAsync(const get_active_guild_threads_data dataPackage)
Lists all of the active threads of a chosen guild.
static co_routine< archived_threads_data > getPrivateArchivedThreadsAsync(const get_private_archived_threads_data dataPackage)
Collects a list of protected archived threads from a given channel.
static co_routine< jsonifier::vector< thread_member_data > > getThreadMembersAsync(const get_thread_members_data dataPackage)
Collects a list of thread_members if they exist.
static co_routine< archived_threads_data > getJoinedPrivateArchivedThreadsAsync(const get_joined_private_archived_threads_data dataPackage)
Collects a list of joined protected archived threads from a given channel.
static co_routine< thread_data > startThreadWithMessageAsync(const start_thread_with_message_data dataPackage)
Starts a thread_data, based on a starting message_data.
static co_routine< thread_data > startThreadWithoutMessageAsync(const start_thread_without_message_data dataPackage)
Starts a thread_data, not based on a starting message_data.
static co_routine< void > removeThreadMemberAsync(const remove_thread_member_data dataPackage)
Removes a user from a chosen thread_data.
The main namespace for the forward-facing interfaces.
Data representing an active thread_data.
For adding a chosen user_data to a chosen thread_data.
snowflake channelId
The id of the thread_data to join.
snowflake userId
The id of the user_data to add to the thread_data.
Data representing an archived thread_data.
Represents a forum thread message.
For listing the active threads in a chosen guild.
snowflake guildId
The guild from which to list the threads from.
For collecting the list of active threads.
snowflake channelId
The id of the channel_data to collect the threads from.
For collecting joined protected archived threads from a given channel.
snowflake channelId
The channel_data to acquire the threads from.
jsonifier::string before
Returns threads before this timeStamp.
int32_t limit
Maximum number of threads to return.
For collecting protected archived threads from a given channel.
jsonifier::string before
Returns threads before this timeStamp.
snowflake channelId
The channel_data to acquire the threads from.
int32_t limit
Maximum number of threads to return.
For collecting puiblic archived threads from a given channel.
snowflake channelId
The channel_data to acquire the threads from.
jsonifier::string before
Returns threads before this timeStamp.
int32_t limit
Maximum number of threads to return.
For collecting a thread_member responseData structure for a given thread_member.
snowflake channelId
The id of the thread_data to collect them from.
snowflake userId
The id of the user_data to collect from the thread_data.
For collecting the list of thread_members from a thread_data.
snowflake channelId
The id of the thread_data to collect them from.
For joining a thread_data.
snowflake channelId
The id of the thread_data to join.
For leaving a thread_data.
snowflake channelId
The id of the thread_data to leave.
For removing a chosen user_data from a thread_data.
snowflake channelId
The id of the thread_data to remove them from.
snowflake userId
The id of the user_data to remove from the thread_data.
For starting a thread_data, in a forum channel.
jsonifier::string reason
Reason for starting the thread_data.
snowflake channelId
The id of the channel.
For starting a thread_data, based on a message.
snowflake channelId
The channel_data to start the thread_data in.
jsonifier::string reason
Reason for starting the thread_data.
snowflake messageId
The message snowflake to base the thread_data off of.
For starting a thread_data, not based on a message.
jsonifier::string reason
Reason for starting the thread_data.
snowflake channelId
The channel_data to start the thread_data in.