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
174 update_voice_state_data data{};
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.jsonifierExcludedKeys.emplace("t");
191 data.jsonifierExcludedKeys.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(const jsonifier::string& authorName, const jsonifier::string& authorAvatarUrl) {
247 author.name = authorName;
248 author.iconUrl = authorAvatarUrl;
249 return *this;
250 }
251
252 embed_data& embed_data::setFooter(const jsonifier::string& footerText, const jsonifier::string& footerIconUrlText) {
253 footer.text = footerText;
254 footer.iconUrl = footerIconUrlText;
255 return *this;
256 }
257
258 embed_data& embed_data::setTimeStamp(const jsonifier::string& timeStampNew) {
259 timeStamp = static_cast<jsonifier::string>(timeStampNew);
260 return *this;
261 }
262
263 embed_data& embed_data::addField(const jsonifier::string& name, const jsonifier::string& 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(const jsonifier::string& descriptionNew) {
273 description = descriptionNew;
274 return *this;
275 }
276
277 embed_data& embed_data::setColor(const jsonifier::string& hexColorValueNew) {
278 hexColorValue = jsonifier::strToUint64<16>(static_cast<jsonifier::string>(hexColorValueNew));
279 return *this;
280 }
281
282 embed_data& embed_data::setThumbnail(const jsonifier::string& thumbnailUrl) {
283 thumbnail.url = thumbnailUrl;
284 return *this;
285 }
286
287 embed_data& embed_data::setTitle(const jsonifier::string& titleNew) {
288 title = titleNew;
289 return *this;
290 }
291
292 embed_data& embed_data::setImage(const jsonifier::string& imageUrl) {
293 image.url = imageUrl;
294 return *this;
295 }
296
297 void embed_image_data::generateExcludedKeys() {
298 if (width == 0) {
299 jsonifierExcludedKeys.emplace("width");
300 }
301 if (height == 0) {
302 jsonifierExcludedKeys.emplace("height");
303 }
304 if (proxyUrl == "") {
305 jsonifierExcludedKeys.emplace("proxy_url");
306 }
307 }
308
309 void embed_author_data::generateExcludedKeys() {
310 if (name == "") {
311 jsonifierExcludedKeys.emplace("name");
312 }
313 if (url == "") {
314 jsonifierExcludedKeys.emplace("url");
315 }
316 if (iconUrl == "") {
317 jsonifierExcludedKeys.emplace("icon_url");
318 }
319 if (proxyIconUrl == "") {
320 jsonifierExcludedKeys.emplace("proxy_icon_url");
321 }
322 }
323
324 void embed_data::generateExcludedKeys() {
325 if (fields.size() == 0) {
326 jsonifierExcludedKeys.emplace("fields");
327 }
328 if (url == "") {
329 jsonifierExcludedKeys.emplace("url");
330 }
331 if (hexColorValue == 0) {
332 jsonifierExcludedKeys.emplace("color");
333 }
334 if (title == "") {
335 jsonifierExcludedKeys.emplace("title");
336 }
337 if (description == "") {
338 jsonifierExcludedKeys.emplace("description");
339 }
340 if (type == "") {
341 jsonifierExcludedKeys.emplace("type");
342 }
343 if (author.iconUrl == "" && author.name == "" && author.proxyIconUrl == "" && author.url == "") {
344 jsonifierExcludedKeys.emplace("author");
345 } else {
346 author.generateExcludedKeys();
347 }
348 if (video.proxyUrl == "" && video.height == 0 && video.width == 0 && video.url == "") {
349 jsonifierExcludedKeys.emplace("video");
350 }
351 if (footer.iconUrl == "" && footer.proxyIconUrl == "" && footer.text == "") {
352 jsonifierExcludedKeys.emplace("footer");
353 }
354 if (image.height == 0 && image.width == 0 && image.proxyUrl == "" && image.url == "") {
355 jsonifierExcludedKeys.emplace("image");
356 }
357 if (provider.name == "" && provider.url == "") {
358 jsonifierExcludedKeys.emplace("provider");
359 }
360 if (thumbnail.height == 0 && thumbnail.width == 0 && thumbnail.proxyUrl == "" && thumbnail.url == "") {
361 jsonifierExcludedKeys.emplace("thumbnail");
362 }
363 if (timeStamp == "") {
364 jsonifierExcludedKeys.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 jsonifierExcludedKeys.emplace("name");
389 }
390 if (id == 0) {
391 jsonifierExcludedKeys.emplace("id");
392 }
393 }
394
395 void emoji_data::generateExcludedKeys() {
396 if (id == 0) {
397 jsonifierExcludedKeys.emplace("id");
398 }
399 if (managed == false) {
400 jsonifierExcludedKeys.emplace("managed");
401 }
402 if (name == "") {
403 jsonifierExcludedKeys.emplace("name");
404 }
405 if (roles.size() == 0) {
406 jsonifierExcludedKeys.emplace("roles");
407 }
408 if (unicodeName.size() == 0) {
409 jsonifierExcludedKeys.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 = makeUnique<interaction_data>(*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 = makeUnique<interaction_data>(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 jsonifierExcludedKeys.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 jsonifierExcludedKeys.emplace("attachments");
513 }
514 if (choices.size() == 0) {
515 jsonifierExcludedKeys.emplace("choices");
516 }
517 if (flags == 0) {
518 jsonifierExcludedKeys.emplace("flags");
519 }
520 if (content == "") {
521 jsonifierExcludedKeys.emplace("content");
522 }
523 if (customId == "") {
524 jsonifierExcludedKeys.emplace("custom_id");
525 }
526 if (files.size() == 0) {
527 jsonifierExcludedKeys.emplace("files");
528 }
529 if (title == "") {
530 jsonifierExcludedKeys.emplace("title");
531 }
532 }
533
534 void action_row_data::generateExcludedKeys() {
535 if (components.size() == 0) {
536 jsonifierExcludedKeys.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 jsonifierExcludedKeys.emplace("custom_id");
549 }
550 if (emoji.name == "") {
551 jsonifierExcludedKeys.emplace("emoji");
552 } else {
553 emoji.generateExcludedKeys();
554 }
555 if (label == "") {
556 jsonifierExcludedKeys.emplace("label");
557 }
558 if (placeholder == "") {
559 jsonifierExcludedKeys.emplace("placeholder");
560 }
561 if (url == "") {
562 jsonifierExcludedKeys.emplace("url");
563 }
564 jsonifierExcludedKeys.emplace("options");
565 jsonifierExcludedKeys.emplace("channel_types");
566 jsonifierExcludedKeys.emplace("placeholder");
567 jsonifierExcludedKeys.emplace("min_values");
568 jsonifierExcludedKeys.emplace("max_values");
569 jsonifierExcludedKeys.emplace("min_length");
570 jsonifierExcludedKeys.emplace("max_length");
571 jsonifierExcludedKeys.emplace("required");
572 jsonifierExcludedKeys.emplace("value");
573 jsonifierExcludedKeys.emplace("title");
574 break;
575 }
577 if (customId == "") {
578 jsonifierExcludedKeys.emplace("custom_id");
579 }
580 if (label == "") {
581 jsonifierExcludedKeys.emplace("label");
582 }
583 if (maxLength == 0) {
584 jsonifierExcludedKeys.emplace("max_length");
585 }
586 if (minLength == 0) {
587 jsonifierExcludedKeys.emplace("min_length");
588 }
589 if (placeholder == "") {
590 jsonifierExcludedKeys.emplace("placeholder");
591 }
592 if (title == "") {
593 jsonifierExcludedKeys.emplace("title");
594 }
595 if (value == "") {
596 jsonifierExcludedKeys.emplace("value");
597 }
598 jsonifierExcludedKeys.emplace("style");
599 jsonifierExcludedKeys.emplace("label");
600 jsonifierExcludedKeys.emplace("emoji");
601 jsonifierExcludedKeys.emplace("url");
602 jsonifierExcludedKeys.emplace("min_length");
603 jsonifierExcludedKeys.emplace("max_length");
604 jsonifierExcludedKeys.emplace("required");
605 jsonifierExcludedKeys.emplace("title");
606 break;
607 }
609 [[fallthrough]];
611 [[fallthrough]];
613 [[fallthrough]];
615 [[fallthrough]];
617 [[fallthrough]];
619 [[fallthrough]];
620 default: {
621 if (customId == "") {
622 jsonifierExcludedKeys.emplace("custom_id");
623 }
624 if (channelTypes.size() == 0) {
625 jsonifierExcludedKeys.emplace("channel_types");
626 }
627 if (label == "") {
628 jsonifierExcludedKeys.emplace("label");
629 }
630 if (maxValues == 0) {
631 jsonifierExcludedKeys.emplace("max_values");
632 }
633 if (minValues == 0) {
634 jsonifierExcludedKeys.emplace("min_values");
635 }
636 if (options.size() == 0) {
637 jsonifierExcludedKeys.emplace("options");
638 }
639 if (placeholder == "") {
640 jsonifierExcludedKeys.emplace("placeholder");
641 }
642 jsonifierExcludedKeys.emplace("style");
643 jsonifierExcludedKeys.emplace("label");
644 jsonifierExcludedKeys.emplace("emoji");
645 jsonifierExcludedKeys.emplace("url");
646 jsonifierExcludedKeys.emplace("min_length");
647 jsonifierExcludedKeys.emplace("max_length");
648 jsonifierExcludedKeys.emplace("required");
649 jsonifierExcludedKeys.emplace("value");
650 jsonifierExcludedKeys.emplace("title");
651 jsonifierExcludedKeys.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 jsonifierExcludedKeys.emplace("max_value");
666 }
667 if (minValue == std::numeric_limits<int64_t>::max()) {
668 jsonifierExcludedKeys.emplace("min_value");
669 }
670 if (nameLocalizations.size() == 0) {
671 jsonifierExcludedKeys.emplace("name_localizations");
672 }
673 if (choices.size() == 0) {
674 jsonifierExcludedKeys.emplace("choices");
675 }
676 if (options.size() == 0) {
677 jsonifierExcludedKeys.emplace("options");
678 }
679 if (!autocomplete) {
680 jsonifierExcludedKeys.emplace("autocomplete");
681 }
682 if (descriptionLocalizations.size() == 0) {
683 jsonifierExcludedKeys.emplace("description_localizations");
684 }
685 if (channelTypes.size() == 0) {
686 jsonifierExcludedKeys.emplace("channel_types");
687 }
688 }
689
690 void application_command_option_choice_data::generateExcludedKeys() {
691 if (nameLocalizations.size() == 0) {
692 jsonifierExcludedKeys.emplace("name_localizations");
693 }
694 }
695
696 void application_command_data::generateExcludedKeys() {
697 if (descriptionLocalizations.size() == 0) {
698 jsonifierExcludedKeys.emplace("description_localizations");
699 }
700 if (nameLocalizations.size() == 0) {
701 jsonifierExcludedKeys.emplace("name_localizations");
702 }
703 if (id == 0) {
704 jsonifierExcludedKeys.emplace("id");
705 }
706 if (version == "") {
707 jsonifierExcludedKeys.emplace("version");
708 }
709 if (guildId == 0) {
710 jsonifierExcludedKeys.emplace("guild_id");
711 }
712 for (auto& value: options) {
713 value.generateExcludedKeys();
714 }
715 if (options.size() == 0) {
716 jsonifierExcludedKeys.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, const jsonifier::string& customIdNew, const jsonifier::string& buttonLabel,
772 button_style buttonStyle, const jsonifier::string& emojiName, snowflake emojiId, const jsonifier::string& 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, const jsonifier::string& customIdNew, const jsonifier::vector<select_option_data>& options,
798 const jsonifier::string& 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(const jsonifier::string& topTitleNew, const jsonifier::string& topCustomIdNew, const jsonifier::string& titleNew,
824 const jsonifier::string& customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, const jsonifier::string& label,
825 const jsonifier::string& 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
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, const jsonifier::string& theName,
889 const unordered_map<jsonifier::string, jsonifier::string>& theNameLocalizations) {
890 application_command_option_choice_data choiceData{};
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, const jsonifier::string& customIdNew, const jsonifier::string& buttonLabel, button_style buttonStyle,
904 const jsonifier::string& emojiName, snowflake emojiId, const jsonifier::string& 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, const jsonifier::string& customIdNew, const jsonifier::vector<select_option_data>& options,
930 const jsonifier::string& 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(const jsonifier::string& topTitleNew, const jsonifier::string& topCustomIdNew, const jsonifier::string& titleNew,
956 const jsonifier::string& customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, const jsonifier::string& label,
957 const jsonifier::string& 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(const jsonifier::string& 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, jsonifier::raw_json_data>& values, application_command_interaction_data_option& data) {
1034 jsonifier::raw_json_data valueNew{};
1035 valueNew = data.value;
1036 values[data.name] = valueNew;
1037 for (auto& value: data.options) {
1038 parseCommandDataOption(values, value);
1039 }
1040 }
1041
1042 serializer_value command_data::getCommandArguments() const {
1043 return optionsArgs;
1044 }
1045
1046 command_data& command_data::operator=(const command_data& other) {
1047 subCommandGroupName = other.subCommandGroupName;
1048 subCommandName = other.subCommandName;
1049 commandName = other.commandName;
1050 optionsArgs = other.optionsArgs;
1051 eventData = makeUnique<input_event_data>(*other.eventData);
1052 return *this;
1053 }
1054
1055 command_data::command_data(const command_data& other) {
1056 *this = other;
1057 }
1058
1059 command_data::command_data(const input_event_data& inputEventData) {
1060 if (inputEventData.interactionData->data.name != "") {
1061 commandName = inputEventData.interactionData->data.name;
1062 }
1063 if (inputEventData.interactionData->data.targetId != 0) {
1064 optionsArgs.values.emplace("target_id", jsonifier::raw_json_data{ inputEventData.interactionData->data.targetId.operator jsonifier::string() });
1065 } else if (inputEventData.interactionData->data.targetId != 0) {
1066 optionsArgs.values.emplace("target_id", jsonifier::raw_json_data{ inputEventData.interactionData->data.targetId.operator jsonifier::string() });
1067 }
1068 eventData = makeUnique<input_event_data>(inputEventData);
1069 for (auto& value: eventData->interactionData->data.options) {
1070 jsonifier::raw_json_data serializer{ value.value.operator jsonifier::string() };
1071 optionsArgs.values[value.name] = serializer;
1072 parseCommandDataOption(optionsArgs.values, value);
1073 }
1074 for (auto& value: eventData->interactionData->data.options) {
1076 subCommandName = value.name;
1077 }
1079 subCommandGroupName = value.name;
1080 }
1081 }
1082 }
1083
1085 return *eventData->interactionData;
1086 }
1087
1089 return eventData->getGuildMemberData();
1090 }
1091
1093 return eventData->getChannelData();
1094 }
1095
1097 return eventData->getMessageData();
1098 }
1099
1101 return eventData->getUserData();
1102 }
1103
1104 jsonifier::string command_data::getCommandName() const {
1105 return commandName;
1106 }
1107
1108 jsonifier::string command_data::getSubCommandName() const {
1109 return subCommandName;
1110 }
1111
1112 jsonifier::string command_data::getSubCommandGroupName() const {
1113 return subCommandGroupName;
1114 }
1115
1117 return *eventData;
1118 }
1119
1120 base_function_arguments::base_function_arguments(const command_data& commanddataNew) : command_data{ commanddataNew } {};
1121
1122 move_through_message_pages_data moveThroughMessagePages(snowflake userID, input_event_data originalEvent, uint32_t currentPageIndex,
1123 const jsonifier::vector<embed_data>& messageEmbeds, bool deleteAfter, uint32_t waitForMaxMs, bool returnResult) {
1125 uint32_t newCurrentPageIndex = currentPageIndex;
1126 stop_watch<milliseconds> stopWatch{ milliseconds{ waitForMaxMs } };
1127 stopWatch.reset();
1128 auto createResponseData = makeUnique<create_interaction_response_data>(originalEvent);
1129 auto interactionResponse = makeUnique<respond_to_input_event_data>(originalEvent);
1130 auto embedData = makeUnique<embed_data>();
1131 embedData->setColor("FEFEFE");
1132 embedData->setTitle("__**Permissions Issue:**__");
1133 embedData->setTimeStamp(getTimeAndDate());
1134 embedData->setDescription("Sorry, but that button can only be pressed by <@" + userID + ">!");
1135 createResponseData->addMessageEmbed(*embedData);
1136 createResponseData->setResponseType(interaction_callback_type::Channel_Message_With_Source);
1137 if (messageEmbeds.size() > 0) {
1138 interactionResponse->addMessageEmbed(messageEmbeds[currentPageIndex]);
1139 }
1140 if (returnResult) {
1141 interactionResponse->addButton(false, "select", "Select", button_style::Success, unicode_emojis::x);
1142 }
1143 interactionResponse->addButton(false, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1144 interactionResponse->addButton(false, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1145 interactionResponse->addButton(false, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1146 interactionResponse->setResponseType(input_event_response_type::Edit_Interaction_Response);
1147 originalEvent = input_events::respondToInputEventAsync(*interactionResponse).get();
1148 while (!stopWatch.hasTimeElapsed()) {
1149 std::this_thread::sleep_for(1ms);
1151 jsonifier::vector<button_response_data> buttonIntData{ button->collectButtonData(false, waitForMaxMs, 1, *createResponseData, userID).get() };
1153 if (buttonIntData.size() == 0) {
1155
1156 dataPackage02->addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1157 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1158 action_row_data actionRow{};
1159 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1160 component_data component = originalEvent.getMessageData().components[x].components[y];
1161 component.disabled = true;
1162 actionRow.components.emplace_back(component);
1163 }
1164 if (returnResult) {
1165 dataPackage02->addButton(false, "select", "Select", button_style::Success, unicode_emojis::x);
1166 }
1167 dataPackage02->addButton(false, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1168 dataPackage02->addButton(false, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1169 dataPackage02->addButton(false, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1170 }
1171 if (deleteAfter == true) {
1172 input_event_data dataPackage03{ originalEvent };
1174 } else {
1175 dataPackage02->setResponseType(input_event_response_type::Edit_Interaction_Response);
1176 input_events::respondToInputEventAsync(*dataPackage02).get();
1177 }
1179 dataPackage03->inputEventData = originalEvent;
1180 dataPackage03->buttonId = "exit";
1181 return *dataPackage03;
1182
1183 } else if (buttonIntData[0].buttonId == "empty" || buttonIntData[0].buttonId == "exit") {
1185 if (buttonIntData[0].buttonId == "empty") {
1186 *dataPackage02 = originalEvent;
1187 } else {
1188 interactionData = makeUnique<interaction_data>(buttonIntData[0]);
1189 *dataPackage02 = respond_to_input_event_data{ *interactionData };
1190 }
1191
1192 dataPackage02->addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1193 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1194 action_row_data actionRow{};
1195 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1196 component_data component = originalEvent.getMessageData().components[x].components[y];
1197 component.disabled = true;
1198 actionRow.components.emplace_back(component);
1199 }
1200 if (returnResult) {
1201 dataPackage02->addButton(true, "select", "Select", button_style::Success, unicode_emojis::x);
1202 }
1203 dataPackage02->addButton(true, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1204 dataPackage02->addButton(true, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1205 dataPackage02->addButton(true, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1206 }
1207 if (deleteAfter == true) {
1208 input_event_data dataPackage03{ originalEvent };
1210 } else {
1211 dataPackage02->setResponseType(input_event_response_type::Edit_Interaction_Response);
1212 input_events::respondToInputEventAsync(*dataPackage02).get();
1213 }
1215 dataPackage03->inputEventData = originalEvent;
1216 dataPackage03->buttonId = "exit";
1217 return *dataPackage03;
1218 } else if (buttonIntData[0].buttonId == "forwards" || buttonIntData[0].buttonId == "backwards") {
1219 if (buttonIntData[0].buttonId == "forwards" && (newCurrentPageIndex == (messageEmbeds.size() - 1))) {
1220 newCurrentPageIndex = 0;
1221 } else if (buttonIntData[0].buttonId == "forwards" && (newCurrentPageIndex < messageEmbeds.size())) {
1222 ++newCurrentPageIndex;
1223 } else if (buttonIntData[0].buttonId == "backwards" && (newCurrentPageIndex > 0)) {
1224 --newCurrentPageIndex;
1225 } else if (buttonIntData[0].buttonId == "backwards" && (newCurrentPageIndex == 0)) {
1226 newCurrentPageIndex = static_cast<uint32_t>(messageEmbeds.size()) - 1;
1227 }
1228 interactionData = makeUnique<interaction_data>(buttonIntData[0]);
1229 auto dataPackage = respond_to_input_event_data{ *interactionData };
1231 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1232 action_row_data actionRow{};
1233 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1234 component_data component = originalEvent.getMessageData().components[x].components[y];
1235 component.disabled = false;
1236 actionRow.components.emplace_back(component);
1237 }
1238 if (returnResult) {
1239 dataPackage.addButton(false, "select", "Select", button_style::Success, unicode_emojis::x);
1240 }
1241 dataPackage.addButton(false, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1242 dataPackage.addButton(false, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1243 dataPackage.addButton(false, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1244 }
1245 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1246 input_events::respondToInputEventAsync(dataPackage).get();
1247 } else if (buttonIntData[0].buttonId == "select") {
1248 if (deleteAfter == true) {
1249 input_event_data dataPackage03{ originalEvent };
1251 } else {
1252 interactionData = makeUnique<interaction_data>(buttonIntData[0]);
1253 auto dataPackage = respond_to_input_event_data{ *interactionData };
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 if (returnResult) {
1263 dataPackage.addButton(true, "select", "Select", button_style::Success, unicode_emojis::x);
1264 }
1265 dataPackage.addButton(true, "backwards", "Prev Page", button_style::Primary, unicode_emojis::arrow_left);
1266 dataPackage.addButton(true, "forwards", "Next Page", button_style::Primary, unicode_emojis::arrow_right);
1267 dataPackage.addButton(true, "exit", "Exit", button_style::Danger, unicode_emojis::x);
1268 }
1269 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1270 input_events::respondToInputEventAsync(dataPackage).get();
1271 }
1272 returnData->currentPageIndex = newCurrentPageIndex;
1273 returnData->inputEventData = originalEvent;
1274 returnData->buttonId = buttonIntData[0].buttonId;
1275 return *returnData;
1276 }
1277 };
1278 return *returnData;
1279 };
1280
1281};
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.
Data structure representing an application_command_data.
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 > jsonifierExcludedKeys
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_provider_data provider
Embed provider data.
unordered_set< jsonifier::string > jsonifierExcludedKeys
For excluding certain keys from parsing/serialization.
embed_image_data image
Embed image data.
jsonifier::string type
Type of the embed.
uint64_t hexColorValue
Hex color value of the embed.
embed_data & setAuthor(const jsonifier::string &authorName, const jsonifier::string &authorAvatarUrl="")
Sets the author's name and avatar for the embed.
embed_data & setImage(const jsonifier::string &imageUrl)
Sets the image of the embed.
embed_data & addField(const jsonifier::string &name, const jsonifier::string &value, bool Inline=true)
Adds a field to the embed.
embed_thumbnail_data thumbnail
Embed thumbnail data.
embed_data & setThumbnail(const jsonifier::string &thumbnailUrl)
Sets the thumbnail of the embed.
jsonifier::string url
Url for the embed.
embed_footer_data footer
Embed footer data.
embed_data & setTitle(const jsonifier::string &titleNew)
Sets the title of the embed.
jsonifier::vector< embed_field_data > fields
Array of embed fields.
embed_video_data video
Embed video data.
embed_data & setFooter(const jsonifier::string &footerText, const jsonifier::string &footerIconUrlText="")
Sets the footer's values for the embed.
embed_data & setColor(const jsonifier::string &hexColorValueNew)
Sets the color of the embed, by applying a hex-color value.
time_stamp timeStamp
Timestamp to be placed on the embed.
embed_data & setTimeStamp(const jsonifier::string &timeStamp)
Sets the timeStamp on the embed.
embed_author_data author
Embed author data.
embed_data & setDescription(const jsonifier::string &descriptionNew)
Sets the description (the main contents) of the embed.
unordered_set< jsonifier::string > jsonifierExcludedKeys
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.
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(respond_to_input_event_data dataPackage)
Responds to one of a number of types of "input_events".
static co_routine< void > deleteInputEventResponseAsync(input_event_data dataPackage, uint32_t timeDelayNew=0)
Deletes a previously sent "input-event-response".
The core of a message's data structure.
Message response base, for responding to messages.
message_response_base & setTTSStatus(bool enabledTTs)
For setting the tts status of a response.
message_response_base & addAllowedMentions(const allowed_mentions_data &dataPackage)
For setting the allowable mentions in a response.
message_response_base & addModal(const jsonifier::string &topTitleNew, const jsonifier::string &topCustomIdNew, const jsonifier::string &titleNew, const jsonifier::string &customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, const jsonifier::string &label="", const jsonifier::string &placeholder="")
Adds a modal to the response message_data.
message_response_base & addContent(const jsonifier::string &dataPackage)
For setting the message content in a response.
message_response_base & addFile(const file &theFile)
Adds a file to the current collection of files for this message response.
message_response_base & addButton(bool disabled, const jsonifier::string &customIdNew, const jsonifier::string &buttonLabel, button_style buttonStyle, const jsonifier::string &emojiName="", snowflake emojiId=snowflake{}, const jsonifier::string &url="")
Adds a button to the response message_data.
message_response_base & addMessageEmbed(const embed_data &dataPackage)
For setting the embeds in a response.
message_response_base & addSelectMenu(bool disabled, const jsonifier::string &customIdNew, const jsonifier::vector< select_option_data > &options, const jsonifier::string &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 & addComponentRow(const action_row_data &dataPackage)
For setting the components in a response.
unordered_set< jsonifier::string > jsonifierExcludedKeys
Excluding keys from parsing/serializing.
jsonifier::string name
What is its name?
Data for responding to an input-event.
respond_to_input_event_data & addButton(bool disabled, const jsonifier::string &customIdNew, const jsonifier::string &buttonLabel, button_style buttonStyle, const jsonifier::string &emojiName="", snowflake emojiId=snowflake{}, const jsonifier::string &url="")
Adds a button to the response message_data.
input_event_response_type type
The type of response to make.
respond_to_input_event_data & addSelectMenu(bool disabled, const jsonifier::string &customIdNew, const jsonifier::vector< select_option_data > &options, const jsonifier::string &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 & addFile(const file &theFile)
Adds a file to the current collection of files for this message response.
respond_to_input_event_data & setAutoCompleteChoice(discord_core_internal::etf_serializer value, const jsonifier::string &theName, const unordered_map< jsonifier::string, jsonifier::string > &theNameLocalizations)
For setting the choices of an autocomplete response.
respond_to_input_event_data & addComponentRow(const action_row_data &dataPackage)
For setting the components in a 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 & addAllowedMentions(const allowed_mentions_data &dataPackage)
For setting the allowable mentions in a response.
respond_to_input_event_data & addContent(const jsonifier::string &dataPackage)
For setting the message content 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 & addModal(const jsonifier::string &topTitleNew, const jsonifier::string &topCustomIdNew, const jsonifier::string &titleNew, const jsonifier::string &customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, const jsonifier::string &label="", const jsonifier::string &placeholder="")
Adds a modal to the response message_data.
A class representing a snowflake identifier with various operations.
Definition Base.hpp:701
uint64_t id
The snowflake id.
Definition Base.hpp:832
A smart pointer class that provides unique ownership semantics.
Definition UniquePtr.hpp:44
DCA_INLINE void reset(pointer newPtr=nullptr)
Resets the managed pointer and invokes the deleter.
static user_cache_data getCachedUser(get_user_data dataPackage)
Collects a given user from the library's cache.
input_event_response_type
Input event response types.
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.
@ Edit_Interaction_Response
Interaction response edit.
@ Channel_Message_With_Source
Respond to an interaction with a message.
@ Action_Row
container for other components.
@ 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.
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.
Application_command_data interaction data option.
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.
jsonifier::string proxyIconUrl
Proxy icon url.
unordered_set< jsonifier::string > jsonifierExcludedKeys
For excluding certain keys from parsing/serialization.
unordered_set< jsonifier::string > jsonifierExcludedKeys
For excluding certain keys from parsing/serialization.
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.
unordered_set< jsonifier::string > jsonifierExcludedKeys
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.
interaction_callback_data data
Interaction application_command_data callback data.