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 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3
4 Copyright 2021, 2022 Chris M. (RealTimeChris)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
20*/
21/// ThreadEntities.hpp - Header file for the thread-related stuff.
22/// Nov 29, 2021
23/// https://discordcoreapi.com
24/// \file ThreadEntities.hpp
25
26#pragma once
27
31
32namespace DiscordCoreAPI {
33
34 /**
35 * \addtogroup foundation_entities
36 * @{
37 */
38
39 /// \brief For starting a Thread, based on a Message.
40 struct DiscordCoreAPI_Dll StartThreadWithMessageData {
41 ThreadAutoArchiveDuration autoArchiveDuration{
42 ThreadAutoArchiveDuration::Shortest
43 };///< The duration before it is auto-archived, in minutes.
44 int32_t rateLimitPerUser{};///< Integer amount of seconds a user has to wait before sending another message(0 - 21600).
45 std::string threadName{};///< The name of the new Thread.
46 Snowflake messageId{};///< The Message Id to base the Thread off of.
47 Snowflake channelId{};///< The Channel to start the Thread in.
48 std::string reason{};///< Reason for starting the Thread.
49
50 operator Serializer();
51 };
52
53 /// \brief For starting a Thread, not based on a Message.
54 struct DiscordCoreAPI_Dll StartThreadWithoutMessageData {
55 ThreadAutoArchiveDuration autoArchiveDuration{
56 ThreadAutoArchiveDuration::Shortest
57 };///< The duration before it is auto-archived, in minutes.
58 ThreadType type{ ThreadType::Guild_Public_Thread };///< Type of Thread to create.
59 int32_t rateLimitPerUser{};///< Integer amount of seconds a user has to wait before sending another message(0 - 21600).
60 std::string threadName{};///< The name of the new Thread.
61 Snowflake channelId{};///< The Channel to start the Thread in.
62 std::string reason{};///< Reason for starting the Thread.
63 bool
64 invitable{};///< Whether non-moderators can add other non - moderators to a thread; only available when creating a private thread.
65
66 operator Serializer();
67 };
68
69 /// \brief For starting a Thread, in a forum channel.
70 struct DiscordCoreAPI_Dll StartThreadInForumChannelData {
71 ThreadAutoArchiveDuration autoArchiveDuration{
72 ThreadAutoArchiveDuration::Longest
73 };/// Duration in minutes to automatically archive.
74 ForumThreadMessageData message{};///< A forum thread message params object contents of the first message in the forum thread.
75 int32_t rateLimitPerUser{};///< Integer amount of seconds a user has to wait before sending another message(0 - 21600).
76 Snowflake channelId{};///< The id of the channel.
77 std::string reason{};///< Reason for starting the Thread.
78 std::string name{};///< 1-100 character channel name auto_archive_duration.
79
80 operator Serializer();
81 };
82
83 /// \brief For joining a Thread.
84 struct DiscordCoreAPI_Dll JoinThreadData {
85 Snowflake channelId{};///< The id of the Thread to join.
86 };
87
88 /// \brief For adding a chosen User to a chosen Thread.
89 struct DiscordCoreAPI_Dll AddThreadMemberData {
90 Snowflake channelId{};///< The id of the Thread to join.
91 Snowflake userId{};///< The id of the User to add to the Thread.
92 };
93
94 /// \brief For leaving a Thread.
95 struct DiscordCoreAPI_Dll LeaveThreadData {
96 Snowflake channelId{};///< The id of the Thread to leave.
97 };
98
99 /// \brief For removing a chosen User from a Thread.
100 struct DiscordCoreAPI_Dll RemoveThreadMemberData {
101 Snowflake channelId{};///< The id of the Thread to remove them from.
102 Snowflake userId{};///< The id of the User to remove from the Thread.
103 };
104
105 /// \brief For collecting a ThreadMember responseData structure for a given ThreadMember.
106 struct DiscordCoreAPI_Dll GetThreadMemberData {
107 Snowflake channelId{};///< The id of the Thread to collect them from.
108 Snowflake userId{};///< The id of the User to collect from the Thread.
109 };
110
111 /// \brief For collecting the list of ThreadMembers from a Thread.
112 struct DiscordCoreAPI_Dll GetThreadMembersData {
113 Snowflake channelId{};///< The id of the Thread to collect them from.
114 };
115
116 /// \brief For collecting the list of active Threads.
117 struct DiscordCoreAPI_Dll GetActiveThreadsData {
118 Snowflake channelId{};///< The id of the Channel to collect the Threads from.
119 };
120
121 /// \brief For collecting puiblic archived Threads from a given Channel.
122 struct DiscordCoreAPI_Dll GetPublicArchivedThreadsData {
123 Snowflake channelId{};///< The Channel to acquire the Threads from.
124 std::string before{};///< Returns threads before this timeStamp.
125 int32_t limit{};///< Maximum number of threads to return.
126 };
127
128 /// \brief For collecting private archived Threads from a given Channel.
129 struct DiscordCoreAPI_Dll GetPrivateArchivedThreadsData {
130 Snowflake channelId{};///< The Channel to acquire the Threads from.
131 std::string before{};///< Returns threads before this timeStamp.
132 int32_t limit{};///< Maximum number of threads to return.
133 };
134
135 /// \brief For collecting joined private archived Threads from a given Channel.
136 struct DiscordCoreAPI_Dll GetJoinedPrivateArchivedThreadsData {
137 Snowflake channelId{};///< The Channel to acquire the Threads from.
138 std::string before{};///< Returns threads before this timeStamp.
139 int32_t limit{};///< Maximum number of threads to return.
140 };
141
142 /// \brief For listing the active Threads in a chosen Guild.
143 struct DiscordCoreAPI_Dll GetActiveGuildThreadsData {
144 Snowflake guildId{};///< The Guild from which to list the Threads from.
145 };
146
147 /// \brief Represents a single Thread.
148 class DiscordCoreAPI_Dll Thread : public Channel {
149 public:
150 Thread() noexcept = default;
151
152 Thread(Value jsonData);
153
154 virtual ~Thread() noexcept = default;
155 };
156
157 /**@}*/
158
159 /**
160 * \addtogroup main_endpoints
161 * @{
162 */
163 /// \brief An interface class for the Thread related endpoints.
164 class DiscordCoreAPI_Dll Threads {
165 public:
166 static void initialize(DiscordCoreInternal::HttpsClient*);
167
168 /// \brief Starts a Thread, based on a starting Message.
169 /// \param dataPackage A StartThreadWithMessageData structure.
170 /// \returns A CoRoutine containing a Channel.
171 static CoRoutine<Thread> startThreadWithMessageAsync(StartThreadWithMessageData dataPackage);
172
173 /// \brief Starts a Thread, not based on a starting Message.
174 /// \param dataPackage A StartThreadWithoutMessageData structure.
175 /// \returns A CoRoutine containing a Channel.
176 static CoRoutine<Thread> startThreadWithoutMessageAsync(StartThreadWithoutMessageData dataPackage);
177
178 /// \brief Starts a Thread, in a forum channel.
179 /// \param dataPackage A StartThreadInForumChannelData structure.
180 /// \returns A CoRoutine containing a Channel.
181 static CoRoutine<Thread> startThreadInForumChannelAsync(StartThreadInForumChannelData dataPackage);
182
183 /// \brief Joins a Thread.
184 /// \param dataPackage A JoinThreadData structure.
185 /// \returns A CoRoutine containing void.
186 static CoRoutine<void> joinThreadAsync(JoinThreadData dataPackage);
187
188 /// \brief Adds a new User to a chosen Thread.
189 /// \param dataPackage An AddThreadMemberData structure.
190 /// \returns A CoRoutine containing void.
191 static CoRoutine<void> addThreadMemberAsync(AddThreadMemberData dataPackage);
192
193 /// \brief Leaves a Thread.
194 /// \param dataPackage A LeaveThreadData structure.
195 /// \returns A CoRoutine containing void.
196 static CoRoutine<void> leaveThreadAsync(LeaveThreadData dataPackage);
197
198 /// \brief Removes a User from a chosen Thread.
199 /// \param dataPackage A RemoveThreadMemberData structure.
200 /// \returns A CoRoutine containing void.
201 static CoRoutine<void> removeThreadMemberAsync(RemoveThreadMemberData dataPackage);
202
203 /// \brief Collects a ThreadMember if they exist.
204 /// \param dataPackage A GetThreadMemberData structure.
205 /// \returns A CoRoutine containing a ThreadMemberData.
206 static CoRoutine<ThreadMemberData> getThreadMemberAsync(GetThreadMemberData dataPackage);
207
208 /// \brief Collects a list of ThreadMembers if they exist.
209 /// \param dataPackage A GetThreadMembersData structure.
210 /// returns A CoRoutine containing a vector<ThreadMemberData>.
211 static CoRoutine<std::vector<ThreadMemberData>> getThreadMembersAsync(GetThreadMembersData dataPackage);
212
213 /// \brief Collects a list of Threads from a given Channel.
214 /// \param dataPackage A GetActiveThreadsData structure.
215 /// \returns A CoRoutine containing a ActiveThreadsData.
216 static CoRoutine<ActiveThreadsData> getActiveThreadsAsync(GetActiveThreadsData dataPackage);
217
218 /// \brief Collects a list of public archived Threads from a given Channel.
219 /// \param dataPackage A GetPublicArchivedThreadsData structure.
220 /// \returns A CoRoutine containing a ArchivedThreadsData.
221 static CoRoutine<ArchivedThreadsData> getPublicArchivedThreadsAsync(GetPublicArchivedThreadsData dataPackage);
222
223 /// \brief Collects a list of private archived Threads from a given Channel.
224 /// \param dataPackage A GetPrivateArchivedThreadsData structure.
225 /// \returns A CoRoutine containing a ArchivedThreadsData.
226 static CoRoutine<ArchivedThreadsData> getPrivateArchivedThreadsAsync(GetPrivateArchivedThreadsData dataPackage);
227
228 /// \brief Collects a list of joined private archived Threads from a given Channel.
229 /// \param dataPackage A GetPrivateArchivedThreadsData structure.
230 /// \returns A CoRoutine containing a ArchivedThreadsData.
231 static CoRoutine<ArchivedThreadsData> getJoinedPrivateArchivedThreadsAsync(GetJoinedPrivateArchivedThreadsData dataPackage);
232
233 /// \brief Lists all of the active Threads of a chosen Guild.
234 /// \param dataPackage A ListActiveThreadsData structure.
235 /// \returns A CoRoutine containing a vector<Channel>.
236 static CoRoutine<ActiveThreadsData> getActiveGuildThreadsAsync(GetActiveGuildThreadsData dataPackage);
237
238 protected:
239 static DiscordCoreInternal::HttpsClient* httpsClient;
240 };
241 /**@}*/
242};// namespace DiscordCoreAPI
ThreadAutoArchiveDuration
Automatic Thread archiving durations.
ThreadType
Thread types.
The main namespace for this library.
A CoRoutine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:52
Represents a forum thread message.
For starting a Thread, based on a Message.
For starting a Thread, not based on a Message.
For starting a Thread, in a forum channel.
For adding a chosen User to a chosen Thread.
For removing a chosen User from a Thread.
For collecting a ThreadMember responseData structure for a given ThreadMember.
For collecting the list of ThreadMembers from a Thread.
For collecting the list of active Threads.
For collecting puiblic archived Threads from a given Channel.
For collecting private archived Threads from a given Channel.
For collecting joined private archived Threads from a given Channel.
For listing the active Threads in a chosen Guild.
Represents a single Thread.
An interface class for the Thread related endpoints.