DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
ReactionEntities.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/// ReactionEntities.hpp - Header for the Reaction related classes and structs.
22/// May 13, 2021
23/// https://discordcoreapi.com
24/// \file ReactionEntities.hpp
25
26#pragma once
27
30
31namespace DiscordCoreAPI {
32
33 /**
34 * \addtogroup foundation_entities
35 * @{
36 */
37 /// \brief For creating a single Reaction.
38 struct DiscordCoreAPI_Dll CreateReactionData {
39 std::string emojiName{};///< The emoji name of the Reaction to add.
40 Snowflake channelId{};///< The Channel for which to add the Reaction.
41 Snowflake messageId{};///< The Message on which to add the Reaction.
42 Snowflake emojiId{};///< The emoji id of the Reaction to add.
43 };
44
45 /// \brief For deleting one's own Reaction.
46 struct DiscordCoreAPI_Dll DeleteOwnReactionData {
47 std::string emojiName{};///< The emoji name for which to remove the emoji.
48 Snowflake channelId{};///< The Channel from which to remove the Reaction.
49 Snowflake messageId{};///< The Message from which to remove the Reaction.
50 Snowflake emojiId{};///< The emoji id for which to remove the emoji.
51 };
52
53 /// \brief For deleting a reaction, by User.
54 struct DiscordCoreAPI_Dll DeleteUserReactionData {
55 std::string emojiName{};///< The name of which emoji to remove.
56 Snowflake channelId{};///< The Channel from which to remove the Reaction.
57 Snowflake messageId{};///< The Message from which to remove the Reaction.
58 Snowflake emojiId{};///< The id of which emoji to remove.
59 Snowflake userId{};///< The User id for whom to remove their emoji.
60 };
61
62 /// \brief For getting all of the Reactions.
63 struct DiscordCoreAPI_Dll GetReactionsData {
64 Snowflake channelId{};///< The Channel from which to acquire the reactors.
65 Snowflake messageId{};///< The Message from which to acquire the reactors.
66 Snowflake afterId{};///< Get users after this user ID.
67 std::string emoji{};///< The emoji name for which to acquire the reactors.
68 int32_t limit{};///< The maximum number of reactors to collect.
69 };
70
71 /// \brief For deleting all of the Reactions on a particular Message.
72 struct DiscordCoreAPI_Dll DeleteAllReactionsData {
73 Snowflake channelId{};///< The Channel from which you would like to remove the emoji.
74 Snowflake messageId{};///< The Message from which you would like to remove the emoji.
75 };
76
77 /// \brief For deleting all of the Reactions of a particular Emoji.
78 struct DiscordCoreAPI_Dll DeleteReactionsByEmojiData {
79 std::string emojiName{};///< The name of which emoji to remove.
80 Snowflake channelId{};///< The Channel from which you would like to remove the emoji.
81 Snowflake messageId{};///< The Message from which you would like to remove the emoji.
82 Snowflake emojiId{};///< The id of which emoji to remove.
83 };
84
85 /// For collecting a list of Emoji from a Guild.
86 struct DiscordCoreAPI_Dll GetEmojiListData {
87 Snowflake guildId{};///< The id of the chosen Guild.
88 };
89
90 /// For collecting a single Guild Emoji.
91 struct DiscordCoreAPI_Dll GetGuildEmojiData {
92 Snowflake guildId{};///< The id of the chosen Guild.
93 Snowflake emojiId{};///< The id of the chosen Emoji
94 };
95
96 enum class ImageType {
97 Jpg = 0,
98 Png = 1,
99 Gif = 2,
100 };
101
102 /// For creating a new Guild Emoji.
103 struct DiscordCoreAPI_Dll CreateGuildEmojiData {
104 friend Reactions;
105
106 std::vector<Snowflake> roles{};///< Roles that can use this Emoji.
107 std::string imageFilePath{};///< The image responseData.
108 std::string reason{};///< Reason for creating the new Emoji.
109 Snowflake guildId{};///< The Guild within which to create the Emoji.
110 std::string name{};///< Name of the emoji.
111 ImageType type{};///< The type of image being uploaded.
112
113 operator Jsonifier();
114
115 protected:
116 std::string imageDataFinal{};
117 };
118
119 /// For modifying a Guild Emoji.
120 struct DiscordCoreAPI_Dll ModifyGuildEmojiData {
121 std::vector<Snowflake> roles{};///< Roles that can use this Emoji.
122 std::string reason{};///< Reason for modifying the Emoji.
123 Snowflake guildId{};///< The Guild within which to modify the Emoji.
124 Snowflake emojiId{};///< The id of the Emoji to modify.
125 std::string name{};///< Name of the Emoji.
126
127 operator Jsonifier();
128 };
129
130 /// For deleting a Guild Emoji.
131 struct DiscordCoreAPI_Dll DeleteGuildEmojiData {
132 std::string reason{};///< Reason for deleting the Emoji.
133 Snowflake guildId{};///< The Guild within which to delete the Emoji.
134 Snowflake emojiId{};///< The id of the Emoji to delete.
135 };
136
137 /// \brief A single Reaction.
138 class DiscordCoreAPI_Dll Reaction : public ReactionData {
139 public:
140 Reaction() noexcept = default;
141
142 Reaction(simdjson::ondemand::value jsonObjectData);
143
144 virtual ~Reaction() noexcept = default;
145 };
146
147 class DiscordCoreAPI_Dll ReactionVector {
148 public:
149 ReactionVector() noexcept = default;
150
151 operator std::vector<Reaction>();
152
153 ReactionVector(simdjson::ondemand::value jsonObjectData);
154
155 virtual ~ReactionVector() noexcept = default;
156
157 protected:
158 std::vector<Reaction> reactions{};
159 };
160
161 /**@}*/
162
163 /**
164 * \addtogroup main_endpoints
165 * @{
166 */
167 /// \brief An interface class for the Reaction related Discord endpoints.
168 class DiscordCoreAPI_Dll Reactions {
169 public:
170 static void initialize(DiscordCoreInternal::HttpsClient*);
171
172 /// \brief Creates a Reaction on a Message.
173 /// \param dataPackage A CreateReactionData structure.
174 /// \returns A CoRoutine containing a Reaction.
175 static CoRoutine<Reaction> createReactionAsync(CreateReactionData dataPackage);
176
177 /// \brief Deletes your own Reactions from a given Message.
178 /// \param dataPackage A DeleteOwnReactionData structure.
179 /// \returns A CoRoutine containing void.
180 static CoRoutine<void> deleteOwnReactionAsync(DeleteOwnReactionData dataPackage);
181
182 /// \brief Deletes all of the Reactions by a specific User from a given Message.
183 /// \param dataPackage A DeleteUserReactionData structure.
184 /// \returns A CoRoutine containing void.
185 static CoRoutine<void> deleteUserReactionAsync(DeleteUserReactionData dataPackage);
186
187 /// \brief Get a list of users that reacted with this emoji. Returns an array of user objects on success.
188 /// \param dataPackage A GetReactionsData structure.
189 /// \returns A CoRoutine containing a UserVector.
190 static CoRoutine<UserVector> getReactionsAsync(GetReactionsData dataPackage);
191
192 /// \brief Deletes all of the Reactions from a given Message.
193 /// \param dataPackage A DeleteAllReactionsData structure.
194 /// \returns A CoRoutine containing void.
195 static CoRoutine<void> deleteAllReactionsAsync(DeleteAllReactionsData dataPackage);
196
197 /// \brief Deletes all of the Reactions by a specific emoji from a given Message.
198 /// \param dataPackage A DeleteReactionsByEmojiData structure.
199 /// \returns A CoRoutine containing void.
200 static CoRoutine<void> deleteReactionsByEmojiAsync(DeleteReactionsByEmojiData dataPackage);
201
202 /// \brief Collects a list of Guild Emoji from a chosen Guild.
203 /// \param dataPackage A GetEmojiListData structure.
204 /// \returns A CoRoutine containing a EmojiDataVector.
205 static CoRoutine<EmojiDataVector> getEmojiListAsync(GetEmojiListData dataPackage);
206
207 /// \brief Collects a single Guild Emoji from a chosen Guild.
208 /// \param dataPackage A GetGuildEmojiData structure.
209 /// \returns A CoRoutine containing an EmojiData.
210 static CoRoutine<EmojiData> getGuildEmojiAsync(GetGuildEmojiData dataPackage);
211
212 /// \brief Creates a single Guild Emoji within a chosen Guild.
213 /// \param dataPackage A CreateGuildEmojiData structure.
214 /// \returns A CoRoutine containing an EmojiData.
215 static CoRoutine<EmojiData> createGuildEmojiAsync(CreateGuildEmojiData dataPackage);
216
217 /// \brief Modifies a single Guild Emoji within a chosen Guild.
218 /// \param dataPackage A ModifyGuildEmojiData structure.
219 /// \returns A CoRoutine containing an EmojiData.
220 static CoRoutine<EmojiData> modifyGuildEmojiAsync(ModifyGuildEmojiData dataPackage);
221
222 /// \brief Deletes a single Guild Emoji within a chosen Guild.
223 /// \param dataPackage A DeleteGuildEmojiData structure.
224 /// \returns A CoRoutine containing void.
225 static CoRoutine<void> deleteGuildEmojiAsync(DeleteGuildEmojiData dataPackage);
226
227 protected:
228 static DiscordCoreInternal::HttpsClient* httpsClient;
229 };
230 /**@}*/
231}// namespace DiscordCoreAPI
The main namespace for this library.
A CoRoutine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:59
/// Data structure representing a single reaction.
For creating a single Reaction.
For deleting one's own Reaction.
For deleting a reaction, by User.
For getting all of the Reactions.
For deleting all of the Reactions on a particular Message.
For deleting all of the Reactions of a particular Emoji.
For collecting a list of Emoji from a Guild.
For collecting a single Guild Emoji.
For creating a new Guild Emoji.
For modifying a Guild Emoji.
An interface class for the Reaction related Discord endpoints.