DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
InteractionEntities.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/// InteractionEntities.hpp - Header for the interaction_data related classes and
27/// structs. may 28, 2021 Chris M.
28/// https://discordcoreapi.com
29/// \file InteractionEntities.hpp
30#pragma once
31
35
36namespace discord_core_api {
37
38 /**
39 * \addtogroup foundation_entities
40 * @{
41 */
42
43 using auto_complete_entry_function = std::function<jsonifier::string(jsonifier::string)>;
44
45 class DiscordCoreAPI_Dll interaction_response_base {
46 public:
47 template<typename value_type> friend struct jsonifier::core;
48
49 unordered_set<jsonifier::string> jsonifierExcludedKeys{};
50
51 /// @brief Adds a button to the response message_data.
52 /// @param disabled whether the button is active or not.
53 /// @param customIdNew a custom id to give for identifying the button.
54 /// @param buttonLabel a visible label for the button.
55 /// @param buttonStyle the style of the button.
56 /// @param emojiName an emoji name, if desired.
57 /// @param emojiId an emoji id, if desired.
58 /// @param url a url, if applicable.
59 interaction_response_base& addButton(bool disabled, jsonifier::string_view customIdNew, jsonifier::string_view buttonLabel, button_style buttonStyle,
60 jsonifier::string_view emojiName = "", snowflake emojiId = snowflake{}, jsonifier::string_view url = "");
61
62 /// @brief Adds a select-menu to the response message_data.
63 /// @param disabled whether the select-menu is active or not.
64 /// @param customIdNew a custom id to give for identifying the select-menu.
65 /// @param options a vector of select-menu-options to offer.
66 /// @param placeholder custom placeholder text if nothing is selected, max 100 characters.
67 /// @param maxValues maximum number of selections that are possible.
68 /// @param minValues minimum required number of selections that are required.
69 interaction_response_base& addSelectMenu(bool disabled, jsonifier::string_view customIdNew, jsonifier::vector<select_option_data> options,
70 jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type type,
71 jsonifier::vector<channel_type> channelTypes = jsonifier::vector<channel_type>{});
72
73 /// @brief Adds a modal to the response message_data.
74 /// @param topTitleNew a title for the modal.
75 /// @param topCustomIdNew a custom id to give for the modal.
76 /// @param titleNew a title for the modal's individual input.
77 /// @param customIdNew a custom id to give for the modal's individual input.
78 /// @param required is it a required response?
79 /// @param minLength minimum length.
80 /// @param maxLength maximum length.
81 /// @param inputStyle the input style.
82 /// @param label a label for the modal.
83 /// @param placeholder a placeholder for the modal.
84 /// @return respond_to_input_event_data& a reference to this data structure.
85 interaction_response_base& addModal(jsonifier::string_view topTitleNew, jsonifier::string_view topCustomIdNew, jsonifier::string_view titleNew,
86 jsonifier::string_view customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, jsonifier::string_view label = "",
87 jsonifier::string_view placeholder = "");
88
89 /// @brief Adds a file to the current collection of files for this message response.
90 /// @param theFile the file to be added.
91 /// @return message_response_base& a reference to this data structure.
92 interaction_response_base& addFile(const file& theFile);
93
94 /// @brief For setting the allowable mentions in a response.
95 /// @param dataPackage an allowed_mentions_data structure.
96 interaction_response_base& addAllowedMentions(const allowed_mentions_data dataPackage);
97
98 /// @brief For setting the components in a response.
99 /// @param dataPackage an action_row_data structure.
100 interaction_response_base& addComponentRow(const action_row_data dataPackage);
101
102 /// @brief Sets the response type of the current message_data.
103 /// @param type interaction callback type.
104 interaction_response_base& setResponseType(interaction_callback_type type);
105
106 /// @brief For setting the embeds in a response.
107 /// @param dataPackage an embed_data structure.send_dmdata
108 interaction_response_base& addMessageEmbed(const embed_data dataPackage);
109
110 /// @brief For setting the content in a response.
111 /// @param dataPackage a string, containing the content.
112 interaction_response_base& addContent(jsonifier::string_view dataPackage);
113
114 /// @brief For setting the tts status of a response.
115 /// @param enabledTTs a bool.
116 interaction_response_base& setTTSStatus(bool enabledTTs);
117
118 interaction_response_base& setFlags(uint64_t flag);
119
120 interaction_response_data getInteractionResponseData();
121
122 void generateExcludedKeys();
123
124 virtual ~interaction_response_base() = default;
125
126 protected:
127 interaction_package_data interactionPackage{};
128 message_package_data messagePackage{};
129 interaction_callback_data data{};
131 };
132
133 /// @brief For creating an ephemeral interaction response.
134 class DiscordCoreAPI_Dll create_ephemeral_interaction_response_data : public interaction_response_base {
135 public:
136 friend class create_interaction_response_data;
137 friend class interactions;
138 friend class input_events;
139
140 create_ephemeral_interaction_response_data(const respond_to_input_event_data dataPackage);
141
142 virtual ~create_ephemeral_interaction_response_data() = default;
143 };
144
145 /// @brief For creating a deferred interaction response.
146 class DiscordCoreAPI_Dll create_deferred_interaction_response_data : public interaction_response_base {
147 public:
148 friend class create_interaction_response_data;
149 friend class interactions;
150 friend class input_events;
151
152 create_deferred_interaction_response_data(const respond_to_input_event_data dataPackage);
153
154 virtual ~create_deferred_interaction_response_data() = default;
155 };
156
157 /// @brief For creating an interaction response.
158 class DiscordCoreAPI_Dll create_interaction_response_data : public interaction_response_base {
159 public:
160 template<typename value_type> friend struct jsonifier::core;
161 friend class select_menu_collector;
162 friend class button_collector;
163 friend class modal_collector;
164 friend class interactions;
165 friend class input_events;
166
167 create_interaction_response_data(const create_ephemeral_interaction_response_data dataPackage);
168
169 create_interaction_response_data(const create_deferred_interaction_response_data dataPackage);
170
171 create_interaction_response_data(const respond_to_input_event_data dataPackage);
172
173 create_interaction_response_data(const interaction_data dataPackage);
174
175 create_interaction_response_data() = default;
176
177 virtual ~create_interaction_response_data() = default;
178 };
179
180 /// @brief For getting an interaction response.
182 jsonifier::string interactionToken{};///< Interaction token.
183 snowflake applicationId{};///< Application id.
184 };
185
186 /// @brief For editing an interaction response.
187 class DiscordCoreAPI_Dll edit_interaction_response_data : public edit_web_hook_data {
188 public:
189 template<typename value_type> friend struct jsonifier::core;
190 friend class interactions;
191 friend class input_events;
192
193 edit_interaction_response_data(const respond_to_input_event_data dataPackage);
194
195 virtual ~edit_interaction_response_data() = default;
196
197 protected:
198 interaction_package_data interactionPackage{};
199 };
200
201 /// @brief For deleting an interaction response.
202 struct DiscordCoreAPI_Dll delete_interaction_response_data {
203 friend class interactions;
204 friend class input_events;
205
206 delete_interaction_response_data(const respond_to_input_event_data dataPackage);
207
208 protected:
209 interaction_package_data interactionPackage{};
210 uint32_t timeDelay{};
211 };
212
213 /// @brief For creating an ephemeral follow up message_data.
215 public:
216 friend class create_follow_up_message_data;
217 friend class interactions;
218 friend class input_events;
219
220 create_ephemeral_follow_up_message_data(const respond_to_input_event_data dataPackage);
221
222 virtual ~create_ephemeral_follow_up_message_data() = default;
223
224 protected:
225 interaction_package_data interactionPackage{};
226 };
227
228 /// @brief For creating a follow up message_data.
229 class DiscordCoreAPI_Dll create_follow_up_message_data : public execute_web_hook_data {
230 public:
231 template<typename value_type> friend struct jsonifier::core;
232 friend class select_menu_collector;
233 friend class button_collector;
234 friend class interactions;
235 friend class input_events;
236
237 create_follow_up_message_data(const create_ephemeral_follow_up_message_data dataPackage);
238
239 create_follow_up_message_data(const respond_to_input_event_data dataPackage);
240
241 virtual ~create_follow_up_message_data() = default;
242
243 protected:
244 interaction_package_data interactionPackage{};
245 };
246
247 /// @brief For getting a follow-up message_data.
249 jsonifier::string interactionToken{};///< Interaction token.
250 snowflake applicationId{};///< Application id.
251 snowflake messageId{};///< Message id.
252 };
253
254 /// @brief For editing a follow up message_data.
255 class DiscordCoreAPI_Dll edit_follow_up_message_data : public edit_web_hook_data {
256 public:
257 template<typename value_type> friend struct jsonifier::core;
258 friend class interactions;
259 friend class input_events;
260
261 edit_follow_up_message_data(const respond_to_input_event_data dataPackage);
262
263 virtual ~edit_follow_up_message_data() = default;
264
265 protected:
266 interaction_package_data interactionPackage{};
267 message_package_data messagePackage{};
268 };
269
270 /// @brief For deleting a follow up message_data.
271 struct DiscordCoreAPI_Dll delete_follow_up_message_data {
272 friend class interactions;
273 friend class input_events;
274
275 delete_follow_up_message_data(const respond_to_input_event_data dataPackage);
276
277 protected:
278 interaction_package_data interactionPackage{};
279 message_package_data messagePackage{};
280 uint32_t timeDelay{};
281 };
282
283 /**@}*/
284
285 /**
286 * \addtogroup main_endpoints
287 * @{
288 */
289
290 /// @brief An interface class for the interaction_data related discord endpoints.
291 class DiscordCoreAPI_Dll interactions {
292 public:
293 friend class discord_core_internal::base_socket_agent;
294 friend class discord_core_client;
295 friend class event_manager;
296 friend class input_events;
297
298 static void initialize(discord_core_internal::https_client*);
299
300 /// @brief Creates a response to an input interaction.
301 /// @param dataPackage a create_interaction_response_data structure.
302 /// @return A co_routine containing a message.
303 static co_routine<message_data> createInteractionResponseAsync(create_interaction_response_data dataPackage);
304
305 /// @brief Collects an interaction response.
306 /// @param dataPackage a get_interaction_response_data structure.
307 /// @return A co_routine containing an interaction_response_data.
308 static co_routine<message_data> getInteractionResponseAsync(get_interaction_response_data dataPackage);
309
310 /// @brief Edits an interaction response.
311 /// @param dataPackage a edit_interaction_response_data structure.
312 /// @return A co_routine containing a message.
313 static co_routine<message_data> editInteractionResponseAsync(edit_interaction_response_data dataPackage);
314
315 /// @brief Deletes an interaction respnose.
316 /// @param dataPackage a delete_interaction_response_data structure.
317 /// @return A co_routine containing void.
318 static co_routine<void> deleteInteractionResponseAsync(delete_interaction_response_data dataPackage);
319
320 /// @brief Creates a follow up message to an input interaction.
321 /// @param dataPackage a create_follow_up_message_data structure.
322 /// @return A co_routine containing a message.
323 static co_routine<message_data> createFollowUpMessageAsync(create_follow_up_message_data dataPackage);
324
325 /// @brief Creates a follow up message to an input interaction.
326 /// @param dataPackage a create_follow_up_message_data structure.
327 /// @return A co_routine containing a message.
328 static co_routine<message_data> getFollowUpMessageAsync(get_follow_up_message_data dataPackage);
329
330 /// @brief Edits a follow up message_data.
331 /// @param dataPackage a edit_follow_up_message_data structure.
332 /// @return A co_routine containing a message.
333 static co_routine<message_data> editFollowUpMessageAsync(edit_follow_up_message_data dataPackage);
334
335 /// @brief Deletes a follow up message_data.
336 /// @param dataPackage a delete_follow_up_message_data structure.
337 /// @return A co_routine containing void.
338 static co_routine<void> deleteFollowUpMessageAsync(delete_follow_up_message_data dataPackage);
339
340 protected:
341 static discord_core_internal::https_client* httpsClient;
342
343 static message_data createInteractionResponse(create_interaction_response_data dataPackage);
344
345 static message_data editInteractionResponse(edit_interaction_response_data dataPackage);
346
347 static message_data getInteractionResponse(get_interaction_response_data dataPackage);
348
349 static message_data createFollowUpMessage(create_follow_up_message_data dataPackage);
350
351 static message_data editFollowUpMessage(edit_follow_up_message_data dataPackage);
352 };
353
354 /**@}*/
355
356 /**
357 * \addtogroup utilities
358 * @{
359 */
360
361 /// @brief Select menu response data.
363 DCA_INLINE operator interaction_data() {
364 return *interactionData;
365 }
366
367 DCA_INLINE select_menu_response_data& operator=(const select_menu_response_data& other) {
368 if (this != &other) {
370 selectionId = other.selectionId;
371 messageId = other.messageId;
372 channelId = other.channelId;
373 values = other.values;
374 userId = other.userId;
375 }
376 return *this;
377 }
378
379 DCA_INLINE select_menu_response_data(const select_menu_response_data& other) {
380 *this = other;
381 }
382
383 DCA_INLINE select_menu_response_data& operator=(select_menu_response_data& other) {
384 if (this != &other) {
386 selectionId = other.selectionId;
387 messageId = other.messageId;
388 channelId = other.channelId;
389 values = other.values;
390 userId = other.userId;
391 }
392 return *this;
393 }
394
395 DCA_INLINE select_menu_response_data(select_menu_response_data& other) {
396 *this = other;
397 }
398
399 DCA_INLINE select_menu_response_data() = default;
400
401 unique_ptr<interaction_data> interactionData{ makeUnique<interaction_data>() };///< Interaction data.
402 jsonifier::vector<jsonifier::string> values{};///< A vector of the chosen values.
403 jsonifier::string selectionId{};///< Selection id.
404 snowflake channelId{};///< The channel_data id where it took place.
405 snowflake messageId{};///< The message id where it took place.
406 snowflake userId{};///< The user_data id who selected the menu options.
407 };
408
409 /// select_menu_collector, for collecting select-menu input from one or more
410 /// @brief Select_menu_collector, for collecting select-menu input from one
411 /// or more users.
412 class DiscordCoreAPI_Dll select_menu_collector {
413 public:
414 friend class discord_core_client;
415
416 static unordered_map<jsonifier::string, unbounded_message_block<interaction_data>*> selectMenuInteractionBuffersMap;
417 static discord_core_internal::trigger_event<void, interaction_data> selectMenuInteractionEventsMap;
418
419 /// @brief Constructor.
420 /// @param dataPackage an input_event_data structure, from the response that came from the submitted select-menu.
421 select_menu_collector(input_event_data dataPackage);
422
423 /// @brief Used to collect the select-menu inputs from one or more users.
424 /// @param getSelectMenuDataForAllNew whether or not to collect select-menu input from a single target user_data or all potential users.
425 /// @param maxWaitTimeInMsNew the maximum amount of time to wait for new inputs, in milliseconds.
426 /// @param maxCollectedSelectMenuCountNew the maximum number of inputs to collect before stopping.
427 /// @param errorMessageDataNew the message-data for when an individual other than the selected individual attemps to use this interaction.
428 /// @param targetUserId the id of the single user_data to collect inputs from, if getSelectMenuDataForAllNew is set to false.
429 /// @return A vector of select_menu_response_data.
430 co_routine<jsonifier::vector<select_menu_response_data>, false> collectSelectMenuData(bool getSelectMenuDataForAllNew, uint32_t maxWaitTimeInMsNew,
431 uint32_t maxCollectedSelectMenuCountNew, create_interaction_response_data errorMessageDataNew, snowflake targetUserId = snowflake{});
432
433 /// @brief Used to collect the select-menu inputs from one or more users.
434 /// @param triggerFunctionNew a std::function<bool(interaction_data)> to decide whether or not to trigger the event's main function.
435 /// @param functionNew takes a discord_core_internal::trigger_event_delegate<void, interaction_data> as a function to be executed upon returning true from the "Trigger-function".
436 void collectSelectMenuData(std::function<bool(interaction_data)> triggerFunctionNew, discord_core_internal::trigger_event_delegate<void, interaction_data> functionNew);
437
438 ~select_menu_collector();
439
440 protected:
441 unbounded_message_block<interaction_data> selectMenuIncomingInteractionBuffer{};
442 unique_ptr<interaction_data> interactionData{ makeUnique<interaction_data>() };
443 jsonifier::vector<select_menu_response_data> responseVector{};
444 create_interaction_response_data errorMessageData{};
445 jsonifier::vector<jsonifier::string> values{};
446 uint32_t currentCollectedSelectMenuCount{};
447 uint32_t maxCollectedSelectMenuCount{};
448 jsonifier::string buffersMapKey{};
449 jsonifier::string selectMenuId{};
450 bool getSelectMenuDataForAll{};
451 uint32_t maxTimeInMs{};
452 snowflake channelId{};
453 snowflake messageId{};
454 snowflake userId{};
455 bool doWeQuit{};
456
457 void run();
458 };
459
460 /// @brief Button response data.
462 DCA_INLINE operator interaction_data() {
463 return *interactionData;
464 }
465
466 DCA_INLINE button_response_data& operator=(const button_response_data& other) {
467 if (this != &other) {
469 messageId = other.messageId;
470 channelId = other.channelId;
471 emojiName = other.emojiName;
472 buttonId = other.buttonId;
473 userId = other.userId;
474 }
475 return *this;
476 }
477
478 DCA_INLINE button_response_data(const button_response_data& other) {
479 *this = other;
480 }
481
482 DCA_INLINE button_response_data& operator=(button_response_data& other) {
483 if (this != &other) {
485 messageId = other.messageId;
486 channelId = other.channelId;
487 emojiName = other.emojiName;
488 buttonId = other.buttonId;
489 userId = other.userId;
490 }
491 return *this;
492 }
493
494 DCA_INLINE button_response_data(button_response_data& other) {
495 *this = other;
496 }
497
498 DCA_INLINE button_response_data() = default;
499
500 unique_ptr<interaction_data> interactionData{ makeUnique<interaction_data>() };///< Interaction data.
501 jsonifier::string emojiName{};///< The emoji name, if applicable.
502 jsonifier::string buttonId{};///< The id of the button, for identification.
503 snowflake channelId{};///< The channel_data id where it took place.
504 snowflake messageId{};///< The message id where it took place.
505 snowflake userId{};///< The user_data id who selected the menu options.
506 };
507
508 /// @brief Button_collector, for collecting button input from one or more users.
509 class DiscordCoreAPI_Dll button_collector {
510 public:
511 friend class discord_core_client;
512
513 static unordered_map<jsonifier::string, unbounded_message_block<interaction_data>*> buttonInteractionBuffersMap;
514 static discord_core_internal::trigger_event<void, interaction_data> buttonInteractionEventsMap;
515
516 /// @brief Constructor.
517 /// @param dataPackage an input_event_data structure, from the response that came from the submitted button.
518 button_collector(input_event_data dataPackage);
519
520 /// @brief Used to collect the button inputs from one or more users.
521 /// @param getButtonDataForAllNew whether or not to collect input from a single target user_data or all potential users.
522 /// @param maxWaitTimeInMsNew the maximum amount of time to wait for new inputs, in milliseconds.
523 /// @param maxNumberOfPressesNew the maximum number of inputs to collect before stopping.
524 /// @param errorMessageDataNew the message-data for when an individual other than the selected individual attemps to use this interaction.
525 /// @param targetUserId the id of the single user_data to collect inputs from, if getButtonDataForAllNew is set to false.
526 /// @return A vector of button_response_data.
527 co_routine<jsonifier::vector<button_response_data>, false> collectButtonData(bool getButtonDataForAllNew, uint32_t maxWaitTimeInMsNew, uint32_t maxNumberOfPressesNew,
528 create_interaction_response_data errorMessageDataNew, snowflake targetUserId = snowflake{});
529
530 /// @brief Used to collect the button inputs from one or more users.
531 /// @param triggerFunctionNew a std::function<bool(interaction_data)> to decide whether or not to trigger the event's main function.
532 /// @param functionNew takes a discord_core_internal::trigger_event_delegate<void, interaction_data> as a function to be executed upon returning true from the "Trigger-function".
533 void collectButtonData(std::function<bool(interaction_data)> triggerFunctionNew, discord_core_internal::trigger_event_delegate<void, interaction_data> functionNew);
534
535 ~button_collector();
536
537 protected:
538 unique_ptr<interaction_data> interactionData{ makeUnique<interaction_data>() };
539 unbounded_message_block<interaction_data> buttonIncomingInteractionBuffer{};
540 jsonifier::vector<button_response_data> responseVector{};
541 create_interaction_response_data errorMessageData{};
542 jsonifier::vector<jsonifier::string> values{};
543 uint32_t currentCollectedButtonCount{};
544 uint32_t maxCollectedButtonCount{};
545 jsonifier::string buffersMapKey{};
546 bool getButtonDataForAll{};
547 uint32_t maxTimeInMs{};
548 jsonifier::string buttonId{};
549 snowflake channelId{};
550 snowflake messageId{};
551 snowflake userId{};
552 bool doWeQuit{};
553
554 void run();
555 };
556
557 /// @brief Button response data.
559 DCA_INLINE operator interaction_data() {
560 return *interactionData;
561 }
562
563 DCA_INLINE modal_response_data& operator=(const modal_response_data& other) {
564 if (this != &other) {
567 channelId = other.channelId;
568 customId = other.customId;
569 userId = other.userId;
570 values = other.values;
571 }
572 return *this;
573 }
574
575 DCA_INLINE modal_response_data(const modal_response_data& other) {
576 *this = other;
577 }
578
579 DCA_INLINE modal_response_data() = default;
580
581 unique_ptr<interaction_data> interactionData{ makeUnique<interaction_data>() };///< Interaction data.
582 jsonifier::vector<jsonifier::string> values{};/// the input values of the modal component.
583 jsonifier::string customIdSmall{};///< The customId of the particular input.
584 jsonifier::string customId{};///< The customId of the modal component.
585 snowflake channelId{};///< The channel_data id where it took place.
586 snowflake userId{};///< The user_data id who selected the menu options.
587 };
588
589 /// @brief Modal_collector, for collecting modal text input from one or more users.
590 class DiscordCoreAPI_Dll modal_collector {
591 public:
592 friend class discord_core_client;
593
594 static unordered_map<jsonifier::string, unbounded_message_block<interaction_data>*> modalInteractionBuffersMap;
595 static discord_core_internal::trigger_event<void, interaction_data> modalInteractionEventsMap;
596
597 /// @brief Constructor.
598 /// @param dataPackage an input_event_data structure, from the response that came from the submitted button.
599 modal_collector(input_event_data dataPackage);
600
601 /// @brief Used to collect the button inputs from one or more users.
602 /// @param maxWaitTimeInMsNew the maximum amount of time to wait for new inputs, in milliseconds.
603 /// @return A vector of button_response_data.
604 co_routine<modal_response_data, false> collectModalData(uint32_t maxWaitTimeInMsNew);
605
606 /// @brief Used to collect the modal from one or more users.
607 /// @param triggerFunctionNew a std::function<bool(interaction_data)> to decide whether or not to trigger the event's main function.
608 /// @param functionNew takes a discord_core_internal::trigger_event_delegate<void, interaction_data> as a function to be executed upon returning true from the "Trigger-function".
609 void collectModalData(std::function<bool(interaction_data)> triggerFunctionNew, discord_core_internal::trigger_event_delegate<void, interaction_data> functionNew);
610
611 ~modal_collector();
612
613 protected:
614 unbounded_message_block<interaction_data> modalIncomingInteractionBuffer{};
615 create_interaction_response_data errorMessageData{};
616 uint32_t currentCollectedButtonCount{};
617 modal_response_data responseData{};
618 uint32_t maxTimeInMs{};
619 snowflake channelId{};
620 bool doWeQuit{};
621
622 void run();
623 };
624
625 /**@}*/
626};
Button_collector, for collecting button input from one or more users.
For creating an ephemeral follow up message_data.
For creating an ephemeral interaction response.
For editing a follow up message_data.
For editing a web_hook message_data.
An interface class for the interaction_data related discord endpoints.
Modal_collector, for collecting modal text input from one or more users.
Select_menu_collector, for collecting select-menu input from one or more users.
interaction_callback_type
Interaction callback types.
DCA_INLINE unique_ptr< value_type, deleter > makeUnique(arg_types &&... args)
Helper function to create a unique_ptr for a non-array object.
The main namespace for the forward-facing interfaces.
snowflake channelId
The channel_data id where it took place.
jsonifier::string buttonId
The id of the button, for identification.
unique_ptr< interaction_data > interactionData
Interaction data.
snowflake messageId
The message id where it took place.
snowflake userId
The user_data id who selected the menu options.
jsonifier::string emojiName
The emoji name, if applicable.
For getting a follow-up message_data.
jsonifier::string interactionToken
Interaction token.
jsonifier::string interactionToken
Interaction token.
snowflake userId
The user_data id who selected the menu options.
snowflake channelId
The channel_data id where it took place.
jsonifier::string customIdSmall
the input values of the modal component.
jsonifier::string customId
The customId of the modal component.
unique_ptr< interaction_data > interactionData
Interaction data.
snowflake messageId
The message id where it took place.
snowflake channelId
The channel_data id where it took place.
unique_ptr< interaction_data > interactionData
Interaction data.
snowflake userId
The user_data id who selected the menu options.
jsonifier::vector< jsonifier::string > values
A vector of the chosen values.