DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
ThreadEntities.hpp
Go to the documentation of this file.
1/*
2 MIT License
3
4 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
5
6 Copyright 2022, 2023 Chris M. (RealTimeChris)
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in all
16 copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25*/
26/// ThreadEntities.hpp - Header file for the thread-related stuff.
27/// Nov 29, 2021
28/// https://discordcoreapi.com
29/// \file ThreadEntities.hpp
30#pragma once
31
35
36namespace discord_core_api {
37
38 /**
39 * \addtogroup foundation_entities
40 * @{
41 */
42
43 /// @brief For starting a thread_data, based on a message.
45 thread_auto_archive_duration autoArchiveDuration{ thread_auto_archive_duration::Shortest };///< The duration before it is auto-archived, in minutes.
46 int32_t rateLimitPerUser{};///< Integer amount of seconds a user has to wait before sending another message(0 - 21600).
47 jsonifier::string threadName{};///< The name of the new thread_data.
48 snowflake messageId{};///< The message snowflake to base the thread_data off of.
49 snowflake channelId{};///< The channel_data to start the thread_data in.
50 jsonifier::string reason{};///< Reason for starting the thread_data.
51 };
52
53 /// @brief For starting a thread_data, not based on a message.
55 thread_auto_archive_duration autoArchiveDuration{ thread_auto_archive_duration::Shortest };///< The duration before it is auto-archived, in minutes.
56 thread_type type{ thread_type::Guild_Public_Thread };///< Type of thread_data to create.
57 int32_t rateLimitPerUser{};///< Integer amount of seconds a user has to wait before sending another message(0 - 21600).
58 jsonifier::string threadName{};///< The name of the new thread_data.
59 snowflake channelId{};///< The channel_data to start the thread_data in.
60 jsonifier::string reason{};///< Reason for starting the thread_data.
61 bool invitable{};///< Whether non-moderators can add other non - moderators to a thread; only available when creating a protected thread.
62 };
63
64 /// @brief For starting a thread_data, in a forum channel.
66 thread_auto_archive_duration autoArchiveDuration{ thread_auto_archive_duration::Longest };/// duration in minutes to automatically archive.
67 forum_thread_message_data message{};///< A forum thread message params object contents of the first message in the forum thread.
68 int32_t rateLimitPerUser{};///< Integer amount of seconds a user has to wait before sending another message(0 - 21600).
69 snowflake channelId{};///< The id of the channel.
70 jsonifier::string reason{};///< Reason for starting the thread_data.
71 jsonifier::string name{};///< 1-100 character channel name auto_archive_duration.
72 };
73
74 /// @brief For joining a thread_data.
76 snowflake channelId{};///< The id of the thread_data to join.
77 };
78
79 /// @brief For adding a chosen user_data to a chosen thread_data.
81 snowflake channelId{};///< The id of the thread_data to join.
82 snowflake userId{};///< The id of the user_data to add to the thread_data.
83 };
84
85 /// @brief For leaving a thread_data.
87 snowflake channelId{};///< The id of the thread_data to leave.
88 };
89
90 /// @brief For removing a chosen user_data from a thread_data.
92 snowflake channelId{};///< The id of the thread_data to remove them from.
93 snowflake userId{};///< The id of the user_data to remove from the thread_data.
94 };
95
96 /// @brief For collecting a thread_member responseData structure for a given thread_member.
98 snowflake channelId{};///< The id of the thread_data to collect them from.
99 snowflake userId{};///< The id of the user_data to collect from the thread_data.
100 };
101
102 /// @brief For collecting the list of thread_members from a thread_data.
104 snowflake channelId{};///< The id of the thread_data to collect them from.
105 };
106
107 /// @brief For collecting the list of active threads.
109 snowflake channelId{};///< The id of the channel_data to collect the threads from.
110 };
111
112 /// @brief For collecting puiblic archived threads from a given channel.
114 snowflake channelId{};///< The channel_data to acquire the threads from.
115 jsonifier::string before{};///< Returns threads before this timeStamp.
116 int32_t limit{};///< Maximum number of threads to return.
117 };
118
119 /// @brief For collecting protected archived threads from a given channel.
121 snowflake channelId{};///< The channel_data to acquire the threads from.
122 jsonifier::string before{};///< Returns threads before this timeStamp.
123 int32_t limit{};///< Maximum number of threads to return.
124 };
125
126 /// @brief For collecting joined protected archived threads from a given channel.
128 snowflake channelId{};///< The channel_data to acquire the threads from.
129 jsonifier::string before{};///< Returns threads before this timeStamp.
130 int32_t limit{};///< Maximum number of threads to return.
131 };
132
133 /// @brief For listing the active threads in a chosen guild.
135 snowflake guildId{};///< The guild from which to list the threads from.
136 };
137
138 /**@}*/
139
140 /**
141 * \addtogroup main_endpoints
142 * @{
143 */
144 /// @brief An interface class for the thread_data related endpoints.
145 class DiscordCoreAPI_Dll threads {
146 public:
147 static void initialize(discord_core_internal::https_client*);
148
149 /// @brief Starts a thread_data, based on a starting message_data.
150 /// @param dataPackage a start_thread_with_message_data structure.
151 /// @return a co_routine containing a channel.
152 static co_routine<thread_data> startThreadWithMessageAsync(const start_thread_with_message_data dataPackage);
153
154 /// @brief Starts a thread_data, not based on a starting message_data.
155 /// @param dataPackage a start_thread_without_message_data structure.
156 /// @return a co_routine containing a channel.
157 static co_routine<thread_data> startThreadWithoutMessageAsync(const start_thread_without_message_data dataPackage);
158
159 /// @brief Starts a thread_data, in a forum channel.
160 /// @param dataPackage a start_thread_in_forum_channel_data structure.
161 /// @return a co_routine containing a channel.
162 static co_routine<thread_data> startThreadInForumChannelAsync(const start_thread_in_forum_channel_data dataPackage);
163
164 /// @brief Joins a thread_data.
165 /// @param dataPackage a join_thread_data structure.
166 /// @return a co_routine containing void.
167 static co_routine<void> joinThreadAsync(const join_thread_data dataPackage);
168
169 /// @brief Adds a new user_data to a chosen thread_data.
170 /// @param dataPackage an add_thread_member_data structure.
171 /// @return a co_routine containing void.
172 static co_routine<void> addThreadMemberAsync(const add_thread_member_data dataPackage);
173
174 /// @brief Leaves a thread_data.
175 /// @param dataPackage a leave_thread_data structure.
176 /// @return a co_routine containing void.
177 static co_routine<void> leaveThreadAsync(const leave_thread_data dataPackage);
178
179 /// @brief Removes a user from a chosen thread_data.
180 /// @param dataPackage a remove_thread_member_data structure.
181 /// @return a co_routine containing void.
182 static co_routine<void> removeThreadMemberAsync(const remove_thread_member_data dataPackage);
183
184 /// @brief Collects a thread_member if they exist.
185 /// @param dataPackage a get_thread_member_data structure.
186 /// @return a co_routine containing a thread_member_data.
187 static co_routine<thread_member_data> getThreadMemberAsync(const get_thread_member_data dataPackage);
188
189 /// @brief Collects a list of thread_members if they exist.
190 /// @param dataPackage a get_thread_members_data structure.
191 /// @return a co_routine containing a vector<thread_member_data>.
192 static co_routine<jsonifier::vector<thread_member_data>> getThreadMembersAsync(const get_thread_members_data dataPackage);
193
194 /// @brief Collects a list of threads from a given channel.
195 /// @param dataPackage a get_active_threads_data structure.
196 /// @return a co_routine containing a active_threads_data.
197 static co_routine<active_threads_data> getActiveThreadsAsync(const get_active_threads_data dataPackage);
198
199 /// @brief Collects a list of public archived threads from a given channel.
200 /// @param dataPackage a get_public_archived_threads_data structure.
201 /// @return a co_routine containing a archived_threads_data.
202 static co_routine<archived_threads_data> getPublicArchivedThreadsAsync(const get_public_archived_threads_data dataPackage);
203
204 /// @brief Collects a list of protected archived threads from a given channel.
205 /// @param dataPackage a get_private_archived_threads_data structure.
206 /// @return a co_routine containing a archived_threads_data.
207 static co_routine<archived_threads_data> getPrivateArchivedThreadsAsync(const get_private_archived_threads_data dataPackage);
208
209 /// @brief Collects a list of joined protected archived threads from a given channel.
210 /// @param dataPackage a get_private_archived_threads_data structure.
211 /// @return a co_routine containing a archived_threads_data.
212 static co_routine<archived_threads_data> getJoinedPrivateArchivedThreadsAsync(const get_joined_private_archived_threads_data dataPackage);
213
214 /// @brief Lists all of the active threads of a chosen guild.
215 /// @param dataPackage a list_active_threads_data structure.
216 /// @return a co_routine containing a vector<channel_data>.
217 static co_routine<active_threads_data> getActiveGuildThreadsAsync(const get_active_guild_threads_data dataPackage);
218
219 protected:
220 static discord_core_internal::https_client* httpsClient;
221 };
222 /**@}*/
223};
A co_routine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:83
A class representing a snowflake identifier with various operations.
Definition: Base.hpp:680
An interface class for the thread_data related endpoints.
thread_type
Thread_data types.
thread_auto_archive_duration
Automatic thread_data archiving durations.
@ Guild_Public_Thread
Guild public thread_data.
The main namespace for the forward-facing interfaces.
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.
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 name
1-100 character channel name auto_archive_duration.
jsonifier::string reason
Reason for starting the thread_data.
forum_thread_message_data message
duration in minutes to automatically archive.
int32_t rateLimitPerUser
Integer amount of seconds a user has to wait before sending another message(0 - 21600).
For starting a thread_data, based on a message.
snowflake channelId
The channel_data to start the thread_data in.
jsonifier::string threadName
The name of the new thread_data.
jsonifier::string reason
Reason for starting the thread_data.
thread_auto_archive_duration autoArchiveDuration
The duration before it is auto-archived, in minutes.
int32_t rateLimitPerUser
Integer amount of seconds a user has to wait before sending another message(0 - 21600).
snowflake messageId
The message snowflake to base the thread_data off of.
For starting a thread_data, not based on a message.
int32_t rateLimitPerUser
Integer amount of seconds a user has to wait before sending another message(0 - 21600).
jsonifier::string reason
Reason for starting the thread_data.
thread_auto_archive_duration autoArchiveDuration
The duration before it is auto-archived, in minutes.
snowflake channelId
The channel_data to start the thread_data in.
thread_type type
Type of thread_data to create.
jsonifier::string threadName
The name of the new thread_data.
bool invitable
Whether non-moderators can add other non - moderators to a thread; only available when creating a pro...