DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
FoundationEntities.cpp
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/// FoundationEntities.cpp - Source file for the foundation entities.
27/// Oct 1, 2021
28/// https://discordcoreapi.com
29/// \file FoundationEntities.cpp
30
44
45namespace discord_core_api {
46
47 namespace discord_core_internal {
48
49 websocket_resume_data::operator discord_core_internal::etf_serializer() {
50 etf_serializer data{};
51 data["seq"] = lastNumberReceived;
52 data["session_id"] = sessionId;
53 data["token"] = botToken;
54 return data;
55 }
56
57 websocket_identify_data::operator discord_core_internal::etf_serializer() {
58 etf_serializer serializer{};
59 serializer["intents"] = intents;
60 serializer["large_threshold"] = 250;
61 serializer["presence"] = presence.operator discord_core_internal::etf_serializer();
62 serializer["properties"]["browser"] = "DiscordCoreAPI";
63 serializer["properties"]["device"] = "DiscordCoreAPI";
64 serializer["properties"]["os"] = properties.os;
65 serializer["shard"].emplaceBack(shard.at(0));
66 serializer["shard"].emplaceBack(shard.at(1));
67 serializer["token"] = botToken;
68 return serializer;
69 }
70
71 https_workload_data& https_workload_data::operator=(https_workload_data&& other) noexcept {
72 if (this != &other) {
73 headersToInsert = std::move(other.headersToInsert);
74 relativePath = std::move(other.relativePath);
75 callStack = std::move(other.callStack);
76 baseUrl = std::move(other.baseUrl);
77 content = std::move(other.content);
78 workloadClass = other.workloadClass;
79 workloadType = other.workloadType;
80 payloadType = other.payloadType;
81 }
82 return *this;
83 }
84
85 https_workload_data::https_workload_data(https_workload_data&& other) noexcept {
86 *this = std::move(other);
87 }
88
89 https_workload_data& https_workload_data::operator=(https_workload_type type) {
90 workloadType = type;
91 return *this;
92 }
93
94 https_workload_type https_workload_data::getWorkloadType() const {
95 return workloadType;
96 }
97
98 https_workload_data::https_workload_data(https_workload_type type) {
99 *this = type;
100 }
101 }
102
103 update_presence_data::operator discord_core_internal::etf_serializer() {
104 discord_core_internal::etf_serializer data{};
105 for (auto& value: activities) {
106 discord_core_internal::etf_serializer newData{};
107 if (value.url != "") {
108 newData["url"] = value.url;
109 }
110 if (value.state != "") {
111 newData["state"] = value.state;
112 }
113 newData["name"] = value.name;
114 newData["type"] = value.type;
115 data["activities"].emplaceBack(newData);
116 }
117 data["status"] = statusReal;
118 data["since"] = since;
119 data["afk"] = false;
120 return data;
121 }
122
123 update_voice_state_data::operator discord_core_internal::etf_serializer() {
124 discord_core_internal::etf_serializer data{};
125 if (channelId == 0) {
126 data["channel_id"] = discord_core_internal::json_type::null_t;
127 } else {
128 data["channel_id"] = channelId.operator jsonifier::string();
129 }
130 data["self_deaf"] = selfDeaf;
131 data["self_mute"] = selfMute;
132 data["guild_id"] = guildId.operator jsonifier::string();
133 return data;
134 }
135
136 update_voice_state_data_dc::operator discord_core_internal::etf_serializer() {
137 discord_core_internal::etf_serializer data{};
138 data["channel_id"] = discord_core_internal::json_type::null_t;
139 data["self_deaf"] = selfDeaf;
140 data["self_mute"] = selfMute;
141 data["guild_id"] = guildId.operator jsonifier::string();
142 return data;
143 }
144
145 voice_state_data_light guild_member_data::getVoiceStateData() {
147 }
148
149 user_cache_data guild_member_data::getUserData() {
150 if (user.id != 0) {
151 return users::getCachedUser({ .userId = user.id });
152 } else {
153 return {};
154 }
155 }
156
157 voice_state_data_light guild_member_cache_data::getVoiceStateData() {
159 }
160
161 user_cache_data guild_member_cache_data::getUserData() {
162 if (user.id != 0) {
163 return users::getCachedUser({ .userId = user.id });
164 } else {
165 return {};
166 }
167 }
168
169 bool guild_cache_data::areWeConnected() {
170 return getDiscordCoreClient()->getVoiceConnection(id).areWeConnected();
171 }
172
175 data.channelId = 0;
176 data.selfDeaf = false;
177 data.selfMute = false;
178 data.guildId = id;
179 discord_core_client::getSongAPI(id).disconnect();
181 discord_core_client::getVoiceConnection(id).disconnect();
182 }
183
184 bool guild_data::areWeConnected() {
185 return getDiscordCoreClient()->getVoiceConnection(id).areWeConnected();
186 }
187
189 discord_core_internal::websocket_message_data<update_voice_state_data> data{};
190 data.excludedKeys.emplace("t");
191 data.excludedKeys.emplace("s");
192 data.d.channelId = 0;
193 data.d.selfDeaf = false;
194 data.d.selfMute = false;
195 data.d.guildId = id;
196 discord_core_client::getSongAPI(id).disconnect();
198 discord_core_client::getVoiceConnection(id).disconnect();
199 }
200
201 bool application_command_option_data::operator==(const application_command_option_data& rhs) const {
202 if (autocomplete != rhs.autocomplete) {
203 return false;
204 }
205 if (channelTypes != rhs.channelTypes) {
206 return false;
207 }
208 if (description != rhs.description) {
209 return false;
210 }
212 return false;
213 }
214 if (maxValue != rhs.maxValue) {
215 return false;
216 }
217 if (minValue != rhs.minValue) {
218 return false;
219 }
220 if (name != rhs.name) {
221 return false;
222 }
224 return false;
225 }
226 if (options.size() != rhs.options.size()) {
227 return false;
228 }
229 if (required != rhs.required) {
230 return false;
231 }
232 if (type != rhs.type) {
233 return false;
234 }
235 if (choices.size() != rhs.choices.size()) {
236 return false;
237 }
238 for (uint64_t x = 0; x < rhs.choices.size(); ++x) {
239 if (choices.at(x) != rhs.choices.at(x)) {
240 return false;
241 }
242 }
243 return true;
244 }
245
246 embed_data& embed_data::setAuthor(jsonifier::string_view authorName, jsonifier::string_view authorAvatarUrl) {
247 author.name = authorName;
248 author.iconUrl = authorAvatarUrl;
249 return *this;
250 }
251
252 embed_data& embed_data::setFooter(jsonifier::string_view footerText, jsonifier::string_view footerIconUrlText) {
253 footer.text = footerText;
254 footer.iconUrl = footerIconUrlText;
255 return *this;
256 }
257
258 embed_data& embed_data::setTimeStamp(jsonifier::string_view timeStampNew) {
259 timeStamp = static_cast<jsonifier::string>(timeStampNew);
260 return *this;
261 }
262
263 embed_data& embed_data::addField(jsonifier::string_view name, jsonifier::string_view value, bool Inline) {
264 embed_field_data field{};
265 field.Inline = Inline;
266 field.value = value;
267 field.name = name;
268 fields.emplace_back(field);
269 return *this;
270 }
271
272 embed_data& embed_data::setDescription(jsonifier::string_view descriptionNew) {
273 description = descriptionNew;
274 return *this;
275 }
276
277 embed_data& embed_data::setColor(jsonifier::string_view hexColorValueNew) {
278 hexColorValue = jsonifier::strToUint64<16>(static_cast<jsonifier::string>(hexColorValueNew));
279 return *this;
280 }
281
282 embed_data& embed_data::setThumbnail(jsonifier::string_view thumbnailUrl) {
283 thumbnail.url = thumbnailUrl;
284 return *this;
285 }
286
287 embed_data& embed_data::setTitle(jsonifier::string_view titleNew) {
288 title = titleNew;
289 return *this;
290 }
291
292 embed_data& embed_data::setImage(jsonifier::string_view imageUrl) {
293 image.url = imageUrl;
294 return *this;
295 }
296
297 void embed_image_data::generateExcludedKeys() {
298 if (width == 0) {
299 excludedKeys.emplace("width");
300 }
301 if (height == 0) {
302 excludedKeys.emplace("height");
303 }
304 if (proxyUrl == "") {
305 excludedKeys.emplace("proxy_url");
306 }
307 }
308
309 void embed_author_data::generateExcludedKeys() {
310 if (name == "") {
311 excludedKeys.emplace("name");
312 }
313 if (url == "") {
314 excludedKeys.emplace("url");
315 }
316 if (iconUrl == "") {
317 excludedKeys.emplace("icon_url");
318 }
319 if (proxyIconUrl == "") {
320 excludedKeys.emplace("proxy_icon_url");
321 }
322 }
323
324 void embed_data::generateExcludedKeys() {
325 if (fields.size() == 0) {
326 excludedKeys.emplace("fields");
327 }
328 if (url == "") {
329 excludedKeys.emplace("url");
330 }
331 if (hexColorValue == 0) {
332 excludedKeys.emplace("color");
333 }
334 if (title == "") {
335 excludedKeys.emplace("title");
336 }
337 if (description == "") {
338 excludedKeys.emplace("description");
339 }
340 if (type == "") {
341 excludedKeys.emplace("type");
342 }
343 if (author.iconUrl == "" && author.name == "" && author.proxyIconUrl == "" && author.url == "") {
344 excludedKeys.emplace("author");
345 } else {
346 author.generateExcludedKeys();
347 }
348 if (video.proxyUrl == "" && video.height == 0 && video.width == 0 && video.url == "") {
349 excludedKeys.emplace("video");
350 }
351 if (footer.iconUrl == "" && footer.proxyIconUrl == "" && footer.text == "") {
352 excludedKeys.emplace("footer");
353 }
354 if (image.height == 0 && image.width == 0 && image.proxyUrl == "" && image.url == "") {
355 excludedKeys.emplace("image");
356 }
357 if (provider.name == "" && provider.url == "") {
358 excludedKeys.emplace("provider");
359 }
360 if (thumbnail.height == 0 && thumbnail.width == 0 && thumbnail.proxyUrl == "" && thumbnail.url == "") {
361 excludedKeys.emplace("thumbnail");
362 }
363 if (timeStamp == "") {
364 excludedKeys.emplace("timestamp");
365 }
366 }
367
368 auto audit_log_data::getAuditLogData(const snowflake userIdOfChanger, audit_log_event auditLogType) {
369 for (auto& value: auditLogEntries) {
370 if (value.id == userIdOfChanger && value.actionType == auditLogType) {
371 return value;
372 }
373 }
374 return audit_log_entry_data();
375 }
376
377 auto audit_log_data::getAuditLogData(audit_log_event auditLogType, const snowflake userIdOfTarget) {
378 for (auto& value: auditLogEntries) {
379 if (value.targetId == userIdOfTarget && value.actionType == auditLogType) {
380 return value;
381 }
382 }
383 return audit_log_entry_data();
384 }
385
386 void partial_emoji_data::generateExcludedKeys() {
387 if (name == "") {
388 excludedKeys.emplace("name");
389 }
390 if (id == 0) {
391 excludedKeys.emplace("id");
392 }
393 }
394
395 void emoji_data::generateExcludedKeys() {
396 if (id == 0) {
397 excludedKeys.emplace("id");
398 }
399 if (managed == false) {
400 excludedKeys.emplace("managed");
401 }
402 if (name == "") {
403 excludedKeys.emplace("name");
404 }
405 if (roles.size() == 0) {
406 excludedKeys.emplace("roles");
407 }
408 if (unicodeName.size() == 0) {
409 excludedKeys.emplace("unicode_name");
410 }
411 }
412
413 bool application_command_data::operator==(const application_command_data& rhs) const {
414 if (description != rhs.description) {
415 return false;
416 }
417 if (name != rhs.name) {
418 return false;
419 }
420 if (type != rhs.type) {
421 return false;
422 }
423 if (options.size() != rhs.options.size()) {
424 return false;
425 }
426 for (uint64_t x = 0; x < options.size(); ++x) {
427 if (options.at(x) != rhs.options.at(x)) {
428 return false;
429 }
430 }
431 return true;
432 }
433
434 bool application_command_option_choice_data::operator==(const application_command_option_choice_data& rhs) const {
435 if (name != rhs.name) {
436 return false;
437 }
438 if (nameLocalizations != rhs.nameLocalizations) {
439 return false;
440 }
441 if (value != rhs.value) {
442 return false;
443 }
444 return true;
445 }
446
447 input_event_data& input_event_data::operator=(input_event_data&& other) noexcept {
448 if (this != &other) {
449 interactionData = std::move(other.interactionData);
450 interactionData.member.guildId = interactionData.guildId;
451 responseType = other.responseType;
452 }
453 return *this;
454 }
455
456 input_event_data::input_event_data(input_event_data&& other) noexcept {
457 *this = std::move(other);
458 }
459
460 input_event_data& input_event_data::operator=(const input_event_data& other) {
461 if (this != &other) {
462 interactionData = other.interactionData;
463 interactionData.member.guildId = interactionData.guildId;
464 responseType = other.responseType;
465 }
466 return *this;
467 }
468
469 input_event_data::input_event_data(const input_event_data& other) {
470 *this = other;
471 }
472
473 input_event_data& input_event_data::operator=(const interaction_data& other) {
474 interactionData = other;
475 interactionData.member.guildId = interactionData.guildId;
476 return *this;
477 }
478
479 input_event_data::input_event_data(const interaction_data& interactionData) {
480 *this = interactionData;
481 }
482
484 if (interactionData.member.user.id != 0) {
485 return interactionData.member.user;
486 } else {
487 return interactionData.user;
488 }
489 }
490
492 return interactionData.channel;
493 }
494
496 return interactionData.member;
497 }
498
499 void interaction_callback_data::generateExcludedKeys() {
500 if (allowedMentions.parse.size() == 0 && allowedMentions.roles.size() == 0 && allowedMentions.users.size() == 0) {
501 excludedKeys.emplace("allowed_mentions");
502 }
503 for (auto& value: components) {
504 for (auto& value02: value.components) {
505 value02.generateExcludedKeys();
506 }
507 }
508 for (auto& value: embeds) {
509 value.generateExcludedKeys();
510 }
511 if (attachments.size() == 0) {
512 excludedKeys.emplace("attachments");
513 }
514 if (choices.size() == 0) {
515 excludedKeys.emplace("choices");
516 }
517 if (flags == 0) {
518 excludedKeys.emplace("flags");
519 }
520 if (content == "") {
521 excludedKeys.emplace("content");
522 }
523 if (customId == "") {
524 excludedKeys.emplace("custom_id");
525 }
526 if (files.size() == 0) {
527 excludedKeys.emplace("files");
528 }
529 if (title == "") {
530 excludedKeys.emplace("title");
531 }
532 }
533
534 void action_row_data::generateExcludedKeys() {
535 if (components.size() == 0) {
536 excludedKeys.emplace("components");
537 } else {
538 for (auto& value: components) {
539 value.generateExcludedKeys();
540 }
541 }
542 }
543
544 void component_data::generateExcludedKeys() {
545 switch (type) {
547 if (customId == "") {
548 excludedKeys.emplace("custom_id");
549 }
550 if (emoji.name == "") {
551 excludedKeys.emplace("emoji");
552 } else {
553 emoji.generateExcludedKeys();
554 }
555 if (label == "") {
556 excludedKeys.emplace("label");
557 }
558 if (placeholder == "") {
559 excludedKeys.emplace("placeholder");
560 }
561 if (url == "") {
562 excludedKeys.emplace("url");
563 }
564 excludedKeys.emplace("options");
565 excludedKeys.emplace("channel_types");
566 excludedKeys.emplace("placeholder");
567 excludedKeys.emplace("min_values");
568 excludedKeys.emplace("max_values");
569 excludedKeys.emplace("min_length");
570 excludedKeys.emplace("max_length");
571 excludedKeys.emplace("required");
572 excludedKeys.emplace("value");
573 excludedKeys.emplace("title");
574 break;
575 }
577 if (customId == "") {
578 excludedKeys.emplace("custom_id");
579 }
580 if (label == "") {
581 excludedKeys.emplace("label");
582 }
583 if (maxLength == 0) {
584 excludedKeys.emplace("max_length");
585 }
586 if (minLength == 0) {
587 excludedKeys.emplace("min_length");
588 }
589 if (placeholder == "") {
590 excludedKeys.emplace("placeholder");
591 }
592 if (title == "") {
593 excludedKeys.emplace("title");
594 }
595 if (value == "") {
596 excludedKeys.emplace("value");
597 }
598 excludedKeys.emplace("style");
599 excludedKeys.emplace("label");
600 excludedKeys.emplace("emoji");
601 excludedKeys.emplace("url");
602 excludedKeys.emplace("min_length");
603 excludedKeys.emplace("max_length");
604 excludedKeys.emplace("required");
605 excludedKeys.emplace("title");
606 break;
607 }
609 [[fallthrough]];
611 [[fallthrough]];
613 [[fallthrough]];
615 [[fallthrough]];
617 [[fallthrough]];
619 [[fallthrough]];
620 default: {
621 if (customId == "") {
622 excludedKeys.emplace("custom_id");
623 }
624 if (channelTypes.size() == 0) {
625 excludedKeys.emplace("channel_types");
626 }
627 if (label == "") {
628 excludedKeys.emplace("label");
629 }
630 if (maxValues == 0) {
631 excludedKeys.emplace("max_values");
632 }
633 if (minValues == 0) {
634 excludedKeys.emplace("min_values");
635 }
636 if (options.size() == 0) {
637 excludedKeys.emplace("options");
638 }
639 if (placeholder == "") {
640 excludedKeys.emplace("placeholder");
641 }
642 excludedKeys.emplace("style");
643 excludedKeys.emplace("label");
644 excludedKeys.emplace("emoji");
645 excludedKeys.emplace("url");
646 excludedKeys.emplace("min_length");
647 excludedKeys.emplace("max_length");
648 excludedKeys.emplace("required");
649 excludedKeys.emplace("value");
650 excludedKeys.emplace("title");
651 excludedKeys.emplace("placeholer");
652 break;
653 }
654 }
655 }
656
657 void application_command_option_data::generateExcludedKeys() {
658 for (auto& value: options) {
659 value.generateExcludedKeys();
660 }
661 for (auto& value: choices) {
662 value.generateExcludedKeys();
663 }
664 if (maxValue == std::numeric_limits<int64_t>::min()) {
665 excludedKeys.emplace("max_value");
666 }
667 if (minValue == std::numeric_limits<int64_t>::max()) {
668 excludedKeys.emplace("min_value");
669 }
670 if (nameLocalizations.size() == 0) {
671 excludedKeys.emplace("name_localizations");
672 }
673 if (choices.size() == 0) {
674 excludedKeys.emplace("choices");
675 }
676 if (options.size() == 0) {
677 excludedKeys.emplace("options");
678 }
679 if (!autocomplete) {
680 excludedKeys.emplace("autocomplete");
681 }
682 if (descriptionLocalizations.size() == 0) {
683 excludedKeys.emplace("description_localizations");
684 }
685 if (channelTypes.size() == 0) {
686 excludedKeys.emplace("channel_types");
687 }
688 }
689
690 void application_command_option_choice_data::generateExcludedKeys() {
691 if (nameLocalizations.size() == 0) {
692 excludedKeys.emplace("name_localizations");
693 }
694 }
695
696 void application_command_data::generateExcludedKeys() {
697 if (descriptionLocalizations.size() == 0) {
698 excludedKeys.emplace("description_localizations");
699 }
700 if (nameLocalizations.size() == 0) {
701 excludedKeys.emplace("name_localizations");
702 }
703 if (id == 0) {
704 excludedKeys.emplace("id");
705 }
706 if (version == "") {
707 excludedKeys.emplace("version");
708 }
709 if (guildId == 0) {
710 excludedKeys.emplace("guild_id");
711 }
712 for (auto& value: options) {
713 value.generateExcludedKeys();
714 }
715 if (options.size() == 0) {
716 excludedKeys.emplace("options");
717 }
718 }
719
721 return interactionData;
722 }
723
725 return interactionData.message;
726 }
727
728 respond_to_input_event_data::operator interaction_callback_data() const {
729 interaction_callback_data returnData{};
730 returnData.allowedMentions = allowedMentions;
731 returnData.components = components;
732 returnData.customId = customId;
733 returnData.choices = choices;
734 returnData.content = content;
735 returnData.embeds = embeds;
736 returnData.files = files;
737 returnData.flags = flags;
738 returnData.title = title;
739 returnData.tts = tts;
740 return returnData;
741 }
742
743 respond_to_input_event_data& respond_to_input_event_data::operator=(const interaction_data dataPackage) {
744 applicationId = dataPackage.applicationId;
745 messageId = dataPackage.message.id;
746 channelId = dataPackage.channelId;
747 interactionToken = dataPackage.token;
748 eventType = dataPackage.type;
749 interactionId = dataPackage.id;
750 return *this;
751 };
752
753 respond_to_input_event_data::respond_to_input_event_data(const interaction_data dataPackage) {
754 *this = dataPackage;
755 }
756
757 respond_to_input_event_data& respond_to_input_event_data::operator=(const input_event_data dataPackage) {
758 applicationId = dataPackage.getInteractionData().applicationId;
759 interactionToken = dataPackage.getInteractionData().token;
760 channelId = dataPackage.interactionData.channelId;
761 interactionId = dataPackage.getInteractionData().id;
762 messageId = dataPackage.getMessageData().id;
763 type = dataPackage.responseType;
764 return *this;
765 }
766
767 respond_to_input_event_data::respond_to_input_event_data(const input_event_data dataPackage) {
768 *this = dataPackage;
769 }
770
771 respond_to_input_event_data& respond_to_input_event_data::addButton(bool disabled, jsonifier::string_view customIdNew, jsonifier::string_view buttonLabel,
772 button_style buttonStyle, jsonifier::string_view emojiName, snowflake emojiId, jsonifier::string_view url) {
773 if (components.size() == 0) {
774 action_row_data actionRowData;
775 components.emplace_back(actionRowData);
776 }
777 if (components.size() < 5) {
778 if (components[components.size() - 1].components.size() < 5) {
779 component_data component;
780 component.type = component_type::Button;
781 component.emoji.name = emojiName;
782 component.label = buttonLabel;
783 component.style = static_cast<uint64_t>(buttonStyle);
784 component.customId = customIdNew;
785 component.disabled = disabled;
786 component.emoji.id = emojiId;
787 component.url = url;
788 components[components.size() - 1].components.emplace_back(component);
789 } else if (components[components.size() - 1].components.size() == 5) {
790 action_row_data actionRowData;
791 components.emplace_back(actionRowData);
792 }
793 }
794 return *this;
795 }
796
797 respond_to_input_event_data& respond_to_input_event_data::addSelectMenu(bool disabled, jsonifier::string_view customIdNew, const jsonifier::vector<select_option_data>& options,
798 jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type typeNew, jsonifier::vector<channel_type> channelTypes) {
799 if (components.size() == 0) {
800 action_row_data actionRowData;
801 components.emplace_back(actionRowData);
802 }
803 if (components.size() < 5) {
804 if (components[components.size() - 1].components.size() < 5) {
805 component_data componentData;
806 componentData.type = static_cast<component_type>(typeNew);
807 componentData.channelTypes = channelTypes;
808 componentData.placeholder = placeholder;
809 componentData.customId = customIdNew;
810 componentData.maxValues = maxValues;
811 componentData.minValues = minValues;
812 componentData.disabled = disabled;
813 componentData.options = options;
814 components[components.size() - 1].components.emplace_back(componentData);
815 } else if (components[components.size() - 1].components.size() == 5) {
816 action_row_data actionRowData;
817 components.emplace_back(actionRowData);
818 }
819 }
820 return *this;
821 }
822
823 respond_to_input_event_data& respond_to_input_event_data::addModal(jsonifier::string_view topTitleNew, jsonifier::string_view topCustomIdNew, jsonifier::string_view titleNew,
824 jsonifier::string_view customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, jsonifier::string_view label,
825 jsonifier::string_view placeholder) {
826 title = topTitleNew;
827 customId = topCustomIdNew;
828 if (components.size() == 0) {
829 action_row_data actionRowData;
830 components.emplace_back(actionRowData);
831 }
832 if (components.size() < 5) {
833 if (components[components.size() - 1].components.size() < 5) {
834 component_data component{};
835 component.type = component_type::Text_Input;
836 component.customId = customIdNew;
837 component.style = static_cast<uint64_t>(inputStyle);
838 component.title = titleNew;
839 component.maxLength = maxLength;
840 component.minLength = minLength;
841 component.label = label;
842 component.required = required;
843 component.placeholder = placeholder;
844 components[components.size() - 1].components.emplace_back(component);
845 } else if (components[components.size() - 1].components.size() == 5) {
846 action_row_data actionRowData;
847 components.emplace_back(actionRowData);
848 }
849 }
850 return *this;
851 }
852
854 files.emplace_back(theFile);
855 return *this;
856 }
857
859 allowedMentions = dataPackage;
860 return *this;
861 }
862
864 type = typeNew;
865 return *this;
866 }
867
869 components.emplace_back(dataPackage);
870 return *this;
871 }
872
874 embeds.emplace_back(dataPackage);
875 return *this;
876 }
877
879 content = dataPackage;
880 return *this;
881 }
882
884 tts = enabledTTs;
885 return *this;
886 }
887
888 respond_to_input_event_data& respond_to_input_event_data::setAutoCompleteChoice(discord_core_internal::etf_serializer value, jsonifier::string_view theName,
889 unordered_map<jsonifier::string, jsonifier::string> theNameLocalizations) {
891 choiceData.nameLocalizations = theNameLocalizations;
892 choiceData.name = theName;
893 choiceData.value = jsonifier::string{ value.operator jsonifier::string_base<uint8_t>() };
894 choices.emplace_back(choiceData);
895 return *this;
896 }
897
899 targetUserId = targetUserIdNew;
900 return *this;
901 }
902
903 message_response_base& message_response_base::addButton(bool disabled, jsonifier::string_view customIdNew, jsonifier::string_view buttonLabel, button_style buttonStyle,
904 jsonifier::string_view emojiName, snowflake emojiId, jsonifier::string_view url) {
905 if (components.size() == 0) {
906 action_row_data actionRowData;
907 components.emplace_back(actionRowData);
908 }
909 if (components.size() < 5) {
910 if (components[components.size() - 1].components.size() < 5) {
911 component_data component;
912 component.type = component_type::Button;
913 component.emoji.name = emojiName;
914 component.label = buttonLabel;
915 component.style = static_cast<uint64_t>(buttonStyle);
916 component.customId = customIdNew;
917 component.disabled = disabled;
918 component.emoji.id = emojiId;
919 component.url = url;
920 components[components.size() - 1].components.emplace_back(component);
921 } else if (components[components.size() - 1].components.size() == 5) {
922 action_row_data actionRowData;
923 components.emplace_back(actionRowData);
924 }
925 }
926 return *this;
927 }
928
929 message_response_base& message_response_base::addSelectMenu(bool disabled, jsonifier::string_view customIdNew, jsonifier::vector<select_option_data> options,
930 jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type type, jsonifier::vector<channel_type> channelTypes) {
931 if (components.size() == 0) {
932 action_row_data actionRowData;
933 components.emplace_back(actionRowData);
934 }
935 if (components.size() < 5) {
936 if (components[components.size() - 1].components.size() < 5) {
937 component_data componentData;
938 componentData.type = static_cast<component_type>(type);
939 componentData.channelTypes = channelTypes;
940 componentData.placeholder = placeholder;
941 componentData.customId = customIdNew;
942 componentData.maxValues = maxValues;
943 componentData.minValues = minValues;
944 componentData.disabled = disabled;
945 componentData.options = options;
946 components[components.size() - 1].components.emplace_back(componentData);
947 } else if (components[components.size() - 1].components.size() == 5) {
948 action_row_data actionRowData;
949 components.emplace_back(actionRowData);
950 }
951 }
952 return *this;
953 }
954
955 message_response_base& message_response_base::addModal(jsonifier::string_view topTitleNew, jsonifier::string_view topCustomIdNew, jsonifier::string_view titleNew,
956 jsonifier::string_view customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, jsonifier::string_view label,
957 jsonifier::string_view placeholder) {
958 title = topTitleNew;
959 customId = topCustomIdNew;
960 if (components.size() == 0) {
961 action_row_data actionRowData;
962 components.emplace_back(actionRowData);
963 }
964 if (components.size() < 5) {
965 if (components[components.size() - 1].components.size() < 5) {
966 component_data component{};
967 component.type = component_type::Text_Input;
968 component.customId = customIdNew;
969 component.style = static_cast<uint64_t>(inputStyle);
970 component.title = titleNew;
971 component.maxLength = maxLength;
972 component.minLength = minLength;
973 component.label = label;
974 component.required = required;
975 component.placeholder = placeholder;
976 components[components.size() - 1].components.emplace_back(component);
977 } else if (components[components.size() - 1].components.size() == 5) {
978 action_row_data actionRowData;
979 components.emplace_back(actionRowData);
980 }
981 }
982 return *this;
983 }
984
986 files.emplace_back(theFile);
987 return *this;
988 }
989
991 allowedMentions = dataPackage;
992 return *this;
993 }
994
996 components.emplace_back(dataPackage);
997 return *this;
998 }
999
1001 embeds.emplace_back(dataPackage);
1002 return *this;
1003 }
1004
1005 message_response_base& message_response_base::addContent(jsonifier::string_view dataPackage) {
1006 content = dataPackage;
1007 return *this;
1008 }
1009
1011 tts = enabledTTs;
1012 return *this;
1013 }
1014
1015 interaction_response_data& interaction_response_data::operator=(const respond_to_input_event_data& other) {
1016 data.allowedMentions = other.allowedMentions;
1017 data.components = other.components;
1018 data.customId = other.customId;
1019 data.choices = other.choices;
1020 data.content = other.content;
1021 data.embeds = other.embeds;
1022 data.title = other.title;
1023 data.files = other.files;
1024 data.flags = other.flags;
1025 data.tts = other.tts;
1026 return *this;
1027 }
1028
1029 interaction_response_data::interaction_response_data(const respond_to_input_event_data& other) {
1030 *this = other;
1031 }
1032
1033 void parseCommandDataOption(unordered_map<jsonifier::string, json_string_value>& values, application_command_interaction_data_option& data) {
1034 json_string_value valueNew{};
1035 auto stringSize{ data.value.operator jsonifier::string_view().size() };
1036 if (stringSize > 1) {
1037 if (data.value.operator jsonifier::string_view().at(0) == '"' && data.value.operator jsonifier::string_view().at(stringSize - 1) == '"') {
1038 data.value = static_cast<jsonifier::string>(data.value.operator jsonifier::string_view().substr(1, data.value.operator jsonifier::string_view().size() - 2));
1039 }
1040 }
1041 valueNew.value = data.value;
1042 values[data.name] = valueNew;
1043 for (auto& value: data.options) {
1044 parseCommandDataOption(values, value);
1045 }
1046 }
1047
1048 serializer_value command_data::getCommandArguments() const {
1049 return optionsArgs;
1050 }
1051
1052 command_data& command_data::operator=(const command_data& other) {
1053 subCommandGroupName = other.subCommandGroupName;
1054 subCommandName = other.subCommandName;
1055 commandName = other.commandName;
1056 optionsArgs = other.optionsArgs;
1057 eventData = other.eventData;
1058 return *this;
1059 }
1060
1061 command_data::command_data(const command_data& other) {
1062 *this = other;
1063 }
1064
1065 command_data::command_data(const input_event_data& inputEventData) {
1066 if (inputEventData.interactionData.data.name != "") {
1067 commandName = inputEventData.interactionData.data.name;
1068 }
1069 if (inputEventData.interactionData.data.targetId != 0) {
1070 optionsArgs.values.emplace("target_id",
1071 json_string_value{ .type = discord_core_internal::json_type::string_t, .value = inputEventData.interactionData.data.targetId.operator jsonifier::string() });
1072 } else if (inputEventData.interactionData.data.targetId != 0) {
1073 optionsArgs.values.emplace("target_id",
1074 json_string_value{ .type = discord_core_internal::json_type::string_t, .value = inputEventData.interactionData.data.targetId.operator jsonifier::string() });
1075 }
1076 eventData = inputEventData;
1077 for (auto& value: eventData.interactionData.data.options) {
1078 json_string_value serializer{ .value = value.value.operator jsonifier::string() };
1079 optionsArgs.values[value.name] = serializer;
1080 parseCommandDataOption(optionsArgs.values, value);
1081 }
1082 for (auto& value: eventData.interactionData.data.options) {
1084 subCommandName = value.name;
1085 }
1087 subCommandGroupName = value.name;
1088 }
1089 }
1090 }
1091
1093 return eventData.interactionData;
1094 }
1095
1097 return eventData.getGuildMemberData();
1098 }
1099
1101 return eventData.getChannelData();
1102 }
1103
1105 return eventData.getMessageData();
1106 }
1107
1109 return eventData.getUserData();
1110 }
1111
1112 jsonifier::string command_data::getCommandName() const {
1113 return commandName;
1114 }
1115
1116 jsonifier::string command_data::getSubCommandName() const {
1117 return subCommandName;
1118 }
1119
1120 jsonifier::string command_data::getSubCommandGroupName() const {
1121 return subCommandGroupName;
1122 }
1123
1125 return eventData;
1126 }
1127
1128 base_function_arguments::base_function_arguments(const command_data& commanddataNew) : command_data{ commanddataNew } {};
1129
1130 move_through_message_pages_data moveThroughMessagePages(snowflake userID, input_event_data originalEvent, uint32_t currentPageIndex,
1131 const jsonifier::vector<embed_data>& messageEmbeds, bool deleteAfter, uint32_t waitForMaxMs, bool returnResult) {
1132 move_through_message_pages_data returnData{};
1133 uint32_t newCurrentPageIndex = currentPageIndex;
1134 stop_watch<milliseconds> stopWatch{ milliseconds{ waitForMaxMs } };
1135 stopWatch.reset();
1136 auto createResponseData = makeUnique<create_interaction_response_data>(originalEvent);
1137 auto interactionResponse = makeUnique<respond_to_input_event_data>(originalEvent);
1138 auto embedData = makeUnique<embed_data>();
1139 embedData->setColor("FEFEFE");
1140 embedData->setTitle("__**Permissions Issue:**__");
1141 embedData->setTimeStamp(getTimeAndDate());
1142 embedData->setDescription("Sorry, but that button can only be pressed by <@" + userID + ">!");
1143 createResponseData->addMessageEmbed(*embedData);
1144 createResponseData->setResponseType(interaction_callback_type::Channel_Message_With_Source);
1145 if (messageEmbeds.size() > 0) {
1146 interactionResponse->addMessageEmbed(messageEmbeds[currentPageIndex]);
1147 }
1148 if (returnResult) {
1149 interactionResponse->addButton(false, "select", "Select", button_style::Success, unicode_emojis::x);
1150 }
1151 interactionResponse->addButton(false, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1152 interactionResponse->addButton(false, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1153 interactionResponse->addButton(false, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1154 interactionResponse->setResponseType(input_event_response_type::Edit_Interaction_Response);
1155 originalEvent = input_events::respondToInputEventAsync(*interactionResponse).get();
1156 while (!stopWatch.hasTimeElapsed()) {
1157 std::this_thread::sleep_for(1ms);
1158 unique_ptr<button_collector> button{ makeUnique<button_collector>(originalEvent) };
1159 jsonifier::vector<button_response_data> buttonIntData{ button->collectButtonData(false, waitForMaxMs, 1, *createResponseData, userID).get() };
1160 unique_ptr<interaction_data> interactionData{ makeUnique<interaction_data>() };
1161 if (buttonIntData.size() == 0) {
1162 unique_ptr<respond_to_input_event_data> dataPackage02{ makeUnique<respond_to_input_event_data>(originalEvent) };
1163
1164 dataPackage02->addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1165 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1166 action_row_data actionRow{};
1167 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1168 component_data component = originalEvent.getMessageData().components[x].components[y];
1169 component.disabled = true;
1170 actionRow.components.emplace_back(component);
1171 }
1172 dataPackage02->addButton(false, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1173 dataPackage02->addButton(false, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1174 dataPackage02->addButton(false, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1175 }
1176 if (deleteAfter == true) {
1177 input_event_data dataPackage03{ originalEvent };
1179 } else {
1180 dataPackage02->setResponseType(input_event_response_type::Edit_Interaction_Response);
1181 input_events::respondToInputEventAsync(*dataPackage02).get();
1182 }
1183 move_through_message_pages_data dataPackage03{};
1184 dataPackage03.inputEventData = originalEvent;
1185 dataPackage03.buttonId = "exit";
1186 return dataPackage03;
1187
1188 } else if (buttonIntData[0].buttonId == "empty" || buttonIntData[0].buttonId == "exit") {
1189 unique_ptr<respond_to_input_event_data> dataPackage02{ makeUnique<respond_to_input_event_data>(originalEvent) };
1190 if (buttonIntData[0].buttonId == "empty") {
1191 *dataPackage02 = originalEvent;
1192 } else {
1193 interactionData = makeUnique<interaction_data>(buttonIntData[0]);
1194 *dataPackage02 = respond_to_input_event_data{ *interactionData };
1195 }
1196
1197 dataPackage02->addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1198 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1199 action_row_data actionRow{};
1200 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1201 component_data component = originalEvent.getMessageData().components[x].components[y];
1202 component.disabled = true;
1203 actionRow.components.emplace_back(component);
1204 }
1205 dataPackage02->addButton(false, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1206 dataPackage02->addButton(false, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1207 dataPackage02->addButton(false, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1208 }
1209 if (deleteAfter == true) {
1210 input_event_data dataPackage03{ originalEvent };
1212 } else {
1213 dataPackage02->setResponseType(input_event_response_type::Edit_Interaction_Response);
1214 input_events::respondToInputEventAsync(*dataPackage02).get();
1215 }
1216 move_through_message_pages_data dataPackage03{};
1217 dataPackage03.inputEventData = originalEvent;
1218 dataPackage03.buttonId = "exit";
1219 return dataPackage03;
1220 } else if (buttonIntData[0].buttonId == "forwards" || buttonIntData[0].buttonId == "backwards") {
1221 if (buttonIntData[0].buttonId == "forwards" && (newCurrentPageIndex == (messageEmbeds.size() - 1))) {
1222 newCurrentPageIndex = 0;
1223 } else if (buttonIntData[0].buttonId == "forwards" && (newCurrentPageIndex < messageEmbeds.size())) {
1224 ++newCurrentPageIndex;
1225 } else if (buttonIntData[0].buttonId == "backwards" && (newCurrentPageIndex > 0)) {
1226 --newCurrentPageIndex;
1227 } else if (buttonIntData[0].buttonId == "backwards" && (newCurrentPageIndex == 0)) {
1228 newCurrentPageIndex = static_cast<uint32_t>(messageEmbeds.size()) - 1;
1229 }
1230 interactionData = makeUnique<interaction_data>(buttonIntData[0]);
1231 auto dataPackage = respond_to_input_event_data{ *interactionData };
1232 dataPackage.setResponseType(input_event_response_type::Edit_Interaction_Response);
1233 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1234 action_row_data actionRow{};
1235 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1236 component_data component = originalEvent.getMessageData().components[x].components[y];
1237 component.disabled = false;
1238 actionRow.components.emplace_back(component);
1239 }
1240 dataPackage.addButton(false, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1241 dataPackage.addButton(false, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1242 dataPackage.addButton(false, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1243 }
1244 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1245 input_events::respondToInputEventAsync(dataPackage).get();
1246 } else if (buttonIntData[0].buttonId == "select") {
1247 if (deleteAfter == true) {
1248 input_event_data dataPackage03{ originalEvent };
1250 } else {
1251 unique_ptr<interaction_data> interactionDataNew = makeUnique<interaction_data>(buttonIntData[0]);
1252 auto dataPackage = respond_to_input_event_data{ *interactionDataNew };
1253 dataPackage.setResponseType(input_event_response_type::Edit_Interaction_Response);
1254 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1255 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1256 action_row_data actionRow{};
1257 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1258 component_data component = originalEvent.getMessageData().components[x].components[y];
1259 component.disabled = true;
1260 actionRow.components.emplace_back(component);
1261 }
1262 dataPackage.addComponentRow(actionRow);
1263 }
1264 originalEvent = input_events::respondToInputEventAsync(dataPackage).get();
1265 }
1266 returnData.currentPageIndex = newCurrentPageIndex;
1267 returnData.inputEventData = originalEvent;
1268 returnData.buttonId = buttonIntData[0].buttonId;
1269 return returnData;
1270 }
1271 };
1272 return returnData;
1273 };
1274
1275};
Action row data of message components.
jsonifier::vector< component_data > components
Array of components to make up the action-row.
Allowable mentions for a message.
jsonifier::vector< jsonifier::string > roles
Array of role_ids to mention (max size of 100)
jsonifier::vector< jsonifier::string > users
Array of user_ids to mention (max size of 100)
jsonifier::vector< jsonifier::string > parse
A vector of allowed mention types to parse from the content.
jsonifier::vector< application_command_option_data > options
A vector of possible options for the current application_command_data.
unordered_map< jsonifier::string, jsonifier::string > descriptionLocalizations
Dictionary with keys in available locales.
application_command_type type
The type of application_command_data.
unordered_set< jsonifier::string > excludedKeys
Keys to exclude at serialization time.
snowflake guildId
(where applicable) a guild id for which guild to assign this application_command_data to.
jsonifier::string description
A description of the current application_command_data.
jsonifier::string version
An autoincremented version.
unordered_map< jsonifier::string, jsonifier::string > nameLocalizations
Dictionary with keys in available locales.
jsonifier::string name
Name of the current application_command_data.
Data structure representing an application_command_data's option choice.
jsonifier::string name
The name of the current choice.
unordered_map< jsonifier::string, jsonifier::string > nameLocalizations
Dictionary with keys in available locales localization dictionary for the name.
jsonifier::raw_json_data value
The value of the option.
jsonifier::vector< audit_log_entry_data > auditLogEntries
Array of audit log entry objects.
void updateVoiceStatus(update_voice_state_data dataPackage)
Updates the bot's current voice-status. joins/leaves a channel, and/or self deafens/mutes.
Command data, for functions executed by the command_controller.
const guild_member_data & getGuildMemberData() const
Returns the guild_member_data of this input-event.
jsonifier::string getSubCommandName() const
Returns the subcommand-name of this entered command.
const input_event_data & getInputEventData() const
Returns the input_event_data for this command.
const user_data & getUserData() const
Returns the user_data of this input-event.
const interaction_data & getInteractionData() const
Returns the interaction data, if appplicable, of this input-event.
jsonifier::string getCommandName() const
Returns the name of this entered command.
const channel_data & getChannelData() const
Returns the channel_data of this input-event.
jsonifier::string getSubCommandGroupName() const
Returns the subcommand-name of this entered command group.
const message_data & getMessageData() const
Returns the message data, if applicable, of this input-event.
serializer_value getCommandArguments() const
Returns the collection of command inputs/options for this command.
static bot_user getBotUser()
For collecting a copy of the current bot's user_data.
jsonifier::string description
Description of the embed.
jsonifier::string title
Title of the embed.
embed_data & setImage(jsonifier::string_view imageUrl)
Sets the image of the embed.
embed_provider_data provider
Embed provider data.
embed_data & setTimeStamp(jsonifier::string_view timeStamp)
Sets the timeStamp on the embed.
embed_image_data image
Embed image data.
jsonifier::string type
Type of the embed.
uint64_t hexColorValue
Hex color value of the embed.
unordered_set< jsonifier::string > excludedKeys
For excluding certain keys from parsing/serialization.
embed_data & addField(jsonifier::string_view name, jsonifier::string_view value, bool Inline=true)
Adds a field to the embed.
embed_thumbnail_data thumbnail
Embed thumbnail data.
embed_data & setFooter(jsonifier::string_view footerText, jsonifier::string_view footerIconUrlText="")
Sets the footer's values for the embed.
jsonifier::string url
Url for the embed.
embed_data & setAuthor(jsonifier::string_view authorName, jsonifier::string_view authorAvatarUrl="")
Sets the author's name and avatar for the embed.
embed_footer_data footer
Embed footer data.
embed_data & setColor(jsonifier::string_view hexColorValueNew)
Sets the color of the embed, by applying a hex-color value.
jsonifier::vector< embed_field_data > fields
Array of embed fields.
embed_video_data video
Embed video data.
time_stamp timeStamp
Timestamp to be placed on the embed.
embed_author_data author
Embed author data.
embed_data & setTitle(jsonifier::string_view titleNew)
Sets the title of the embed.
embed_data & setDescription(jsonifier::string_view descriptionNew)
Sets the description (the main contents) of the embed.
embed_data & setThumbnail(jsonifier::string_view thumbnailUrl)
Sets the thumbnail of the embed.
unordered_set< jsonifier::string > excludedKeys
Excluding keys from parsing/serializing.
std::wstring unicodeName
What is its unicode name?
jsonifier::vector< role_data > roles
Roles that are allowed to use this emoji.
void disconnect()
For disconnecting from the current guild's voice channel.
snowflake id
The id of this guild.
void disconnect()
For disconnecting from the current guild's voice channel.
user_id_base user
The user id for this guild_member_data.
Data structure representing a single guild_member_data.
snowflake guildId
The guild that this member belongs to.
user_data user
The user this guild member represents.
static voice_state_data_light getVoiceStateData(const two_id_key &voiceState)
Collect a given guild_member's voice state data.
Data representing an input-event, which is any message or interaction that is coming into the bot as ...
const guild_member_data & getGuildMemberData() const
Returns the guild_member_data of this input-event.
const channel_data & getChannelData() const
Returns the channel_data of this input-event.
const interaction_data & getInteractionData() const
Returns the interaction data, if appplicable, of this input-event.
input_event_response_type responseType
The type of response that this input value represents.
const user_data & getUserData() const
Returns the user_data of this input-event.
const message_data & getMessageData() const
Returns the message data, if applicable, of this input-event.
static co_routine< input_event_data > respondToInputEventAsync(const respond_to_input_event_data dataPackage)
Responds to one of a number of types of "input_events".
Definition: InputEvents.cpp:38
static co_routine< void > deleteInputEventResponseAsync(const input_event_data dataPackage, uint32_t timeDelayNew=0)
Deletes a previously sent "input-event-response".
Data structure representing a single message_data.
Message response base, for responding to messages.
message_response_base & addButton(bool disabled, jsonifier::string_view customIdNew, jsonifier::string_view buttonLabel, button_style buttonStyle, jsonifier::string_view emojiName="", snowflake emojiId=snowflake{}, jsonifier::string_view url="")
Adds a button to the response message_data.
message_response_base & addSelectMenu(bool disabled, jsonifier::string_view customIdNew, jsonifier::vector< select_option_data > options, jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type type, jsonifier::vector< channel_type > channelTypes=jsonifier::vector< channel_type >{})
Adds a select-menu to the response message_data.
message_response_base & setTTSStatus(bool enabledTTs)
For setting the tts status of a response.
message_response_base & addModal(jsonifier::string_view topTitleNew, jsonifier::string_view topCustomIdNew, jsonifier::string_view titleNew, jsonifier::string_view customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, jsonifier::string_view label="", jsonifier::string_view placeholder="")
Adds a modal to the response message_data.
message_response_base & addMessageEmbed(const embed_data dataPackage)
For setting the embeds in a response.
message_response_base & addContent(jsonifier::string_view dataPackage)
For setting the message content in a response.
message_response_base & addAllowedMentions(const allowed_mentions_data dataPackage)
For setting the allowable mentions in a response.
message_response_base & addFile(file theFile)
Adds a file to the current collection of files for this message response.
message_response_base & addComponentRow(const action_row_data dataPackage)
For setting the components in a response.
unordered_set< jsonifier::string > excludedKeys
Excluding keys from parsing/serializing.
jsonifier::string name
What is its name?
Data for responding to an input-event.
respond_to_input_event_data & setAutoCompleteChoice(discord_core_internal::etf_serializer value, jsonifier::string_view theName, unordered_map< jsonifier::string, jsonifier::string > theNameLocalizations)
For setting the choices of an autocomplete response.
respond_to_input_event_data & addContent(jsonifier::string_view dataPackage)
For setting the message content in a response.
respond_to_input_event_data & addAllowedMentions(const allowed_mentions_data dataPackage)
For setting the allowable mentions in a response.
input_event_response_type type
The type of response to make.
respond_to_input_event_data & addFile(const file &theFile)
Adds a file to the current collection of files for this message response.
respond_to_input_event_data & setTTSStatus(bool enabledTTs)
For setting the tts status of a response.
respond_to_input_event_data & addMessageEmbed(const embed_data dataPackage)
For setting the embeds in a response.
respond_to_input_event_data & setResponseType(input_event_response_type typeNew)
For setting the type of response to make.
respond_to_input_event_data & setTargetUserID(const snowflake targetUserIdNew)
For setting the direct-message_data user target of a response.
respond_to_input_event_data & addSelectMenu(bool disabled, jsonifier::string_view customIdNew, const jsonifier::vector< select_option_data > &options, jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type type, jsonifier::vector< channel_type > channelTypes=jsonifier::vector< channel_type >{})
Adds a select-menu to the response message_data.
respond_to_input_event_data & addComponentRow(const action_row_data dataPackage)
For setting the components in a response.
respond_to_input_event_data & addModal(jsonifier::string_view topTitleNew, jsonifier::string_view topCustomIdNew, jsonifier::string_view titleNew, jsonifier::string_view customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, jsonifier::string_view label="", jsonifier::string_view placeholder="")
Adds a modal to the response message_data.
respond_to_input_event_data & addButton(bool disabled, jsonifier::string_view customIdNew, jsonifier::string_view buttonLabel, button_style buttonStyle, jsonifier::string_view emojiName="", snowflake emojiId=snowflake{}, jsonifier::string_view url="")
Adds a button to the response message_data.
A class representing a snowflake identifier with various operations.
Definition: Base.hpp:680
uint64_t id
The snowflake id.
Definition: Base.hpp:811
snowflake id
The user's id.
static user_cache_data getCachedUser(const get_user_data dataPackage)
Collects a given user from the library's cache.
input_event_response_type
Input event response types.
Definition: Utilities.hpp:151
button_style
Button styles.
audit_log_event
Audit log events.
text_input_style
Text input style for modals.
component_type
Component types.
DiscordCoreAPI_Dll jsonifier::string getTimeAndDate()
Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
Definition: Utilities.cpp:632
@ Edit_Interaction_Response
Interaction response edit.
@ Channel_Message_With_Source
Respond to an interaction with a message.
@ Action_Row
container for other components.
@ Role_Select
Select menu for roles.
@ Mentionable_Select
Select menu for mentionables (users and roles).
@ Channel_Select
Select menu for channels.
@ String_Select
Select menu for picking from defined text options.
@ User_Select
Select menu for users.
@ Text_Input
Text input object.
The main namespace for the forward-facing interfaces.
Data structure representing an application_command_data's option.
int64_t minValue
If the option is an integer or number type, the minimum value permitted.
bool autocomplete
If autocomplete interactions are enabled for this string, integer, or number type option.
jsonifier::string description
A description of the current application_command_data option.
jsonifier::vector< channel_type > channelTypes
Set when the application_command_data option type is set to channel_data.
bool required
If the parameter is required or optional– default false.
jsonifier::vector< application_command_option_choice_data > choices
A vector of possible choices for the current application_command_data option.
jsonifier::vector< application_command_option_data > options
A vector of possible options for the current application_command_data option.
jsonifier::string name
Name of the current application_command_data option.
application_command_option_type type
The type of command option.
unordered_map< jsonifier::string, jsonifier::string > nameLocalizations
Dictionary for the name localizations field.
int64_t maxValue
If the option is an integer or number type, the maximum value permitted.
unordered_map< jsonifier::string, jsonifier::string > descriptionLocalizations
Dictionary for the description localizations field.
unordered_set< jsonifier::string > excludedKeys
For excluding certain keys from parsing/serialization.
jsonifier::string proxyIconUrl
Proxy icon url.
bool Inline
Is the field inline with the rest of them?
unordered_set< jsonifier::string > excludedKeys
For excluding certain keys from parsing/serialization.
jsonifier::string proxyUrl
Proxy url.
jsonifier::string proxyUrl
Proxy url.
Data representing a file to be sent via multipart-form data.
Interaction application_command_data callback data.
jsonifier::vector< action_row_data > components
Message components.
jsonifier::string title
The title of the popup modal.
jsonifier::vector< file > files
Files for uploading.
jsonifier::vector< attachment_data > attachments
Array of partial attachment objects attachment objects with filename and description.
jsonifier::string customId
A developer-defined identifier for the component, max 100 characters.
allowed_mentions_data allowedMentions
Allowed mentions data.
jsonifier::string content
Message content.
unordered_set< jsonifier::string > excludedKeys
Keys to exclude from parsing/serializing.
jsonifier::vector< application_command_option_choice_data > choices
Autocomplete choices(max of 25 choices).
jsonifier::vector< embed_data > embeds
Message embeds.
jsonifier::vector< application_command_interaction_data_option > options
Application_command_data interaction data options.
interaction_callback_data data
Interaction application_command_data callback data.
For updating the current voice state.
snowflake channelId
snowflake of the desired voice channel_data. leave blank to disconnect.