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 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3
4 Copyright 2021, 2022 Chris M. (RealTimeChris)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
20*/
21/// FoundationEntities.cpp - Source file for the foundation entities.
22/// Oct 1, 2021
23/// https://discordcoreapi.com
24/// \file FoundationEntities.cpp
25
39
40namespace DiscordCoreInternal {
41
42 WebSocketResumeData::operator DiscordCoreAPI::Jsonifier() {
43 DiscordCoreAPI::Jsonifier data{};
44 data["op"] = 6;
45 data["d"]["seq"] = this->lastNumberReceived;
46 data["d"]["session_id"] = this->sessionId;
47 data["d"]["token"] = this->botToken;
48 return data;
49 }
50
51 WebSocketIdentifyData::operator DiscordCoreAPI::Jsonifier() {
52 DiscordCoreAPI::Jsonifier serializer{};
53 serializer["d"]["intents"] = this->intents;
54 serializer["d"]["large_threshold"] = 250;
55 for (auto& value: this->presence.activities) {
56 DiscordCoreAPI::Jsonifier serializer01{};
57 if (value.url != "") {
58 serializer01["url"] = value.url;
59 }
60 serializer01["name"] = value.name;
61 serializer01["type"] = value.type;
62 serializer["d"]["presence"]["activities"].emplaceBack(serializer01);
63 }
64 serializer["d"]["presence"]["afk"] = this->presence.afk;
65 if (this->presence.since != 0) {
66 serializer["d"]["presence"]["since"] = this->presence.since;
67 }
68 switch (this->presence.status) {
70 serializer["d"]["presence"]["status"] = "online";
71 break;
72 }
74 serializer["d"]["presence"]["status"] = "dnd";
75 break;
76 }
78 serializer["d"]["presence"]["status"] = "invisible";
79 break;
80 }
82 serializer["d"]["presence"]["status"] = "offline";
83 break;
84 }
86 serializer["d"]["presence"]["status"] = "idle";
87 break;
88 }
89 }
90 serializer["d"]["properties"]["browser"] = "DiscordCoreAPI";
91 serializer["d"]["properties"]["device"] = "DiscordCoreAPI";
92#ifdef _WIN32
93 serializer["d"]["properties"]["os"] = "Windows";
94#elif __linux__
95 serializer["d"]["properties"]["os"] = "Linux";
96#endif
97 serializer["d"]["shard"].emplaceBack(this->currentShard);
98 serializer["d"]["shard"].emplaceBack(this->numberOfShards);
99 serializer["d"]["token"] = this->botToken;
100 serializer["op"] = 2;
101 return serializer;
102 }
103
104 VoiceSocketProtocolPayloadData::operator DiscordCoreAPI::Jsonifier() {
105 DiscordCoreAPI::Jsonifier data{};
106 data["op"] = 1;
107 data["d"]["protocol"] = "udp";
108 data["d"]["data"]["port"] = this->voicePort;
109 data["d"]["data"]["mode"] = this->voiceEncryptionMode;
110 std::string externalIpReal{};
111 for (auto& value: this->externalIp) {
112 externalIpReal.push_back(value);
113 }
114 data["d"]["data"]["address"] = externalIpReal;
115 return data;
116 }
117
118 VoiceIdentifyData::operator DiscordCoreAPI::Jsonifier() {
119 DiscordCoreAPI::Jsonifier data{};
120 data["op"] = 0;
121 data["d"]["session_id"] = this->connectionData.sessionId;
122 data["d"]["token"] = this->connectionData.token;
123 data["d"]["server_id"] = this->connectInitData.guildId;
124 data["d"]["user_id"] = this->connectInitData.userId;
125 return data;
126 }
127
128 SendSpeakingData::operator DiscordCoreAPI::Jsonifier() {
129 DiscordCoreAPI::Jsonifier data{};
130 data["op"] = 5;
131 data["d"]["speaking"] = static_cast<int32_t>(this->type);
132 data["d"]["delay"] = this->delay;
133 data["d"]["ssrc"] = this->ssrc;
134 return data;
135 }
136
137 HttpsWorkloadData& HttpsWorkloadData::operator=(HttpsWorkloadData&& other) noexcept {
138 if (this != &other) {
139 this->headersToInsert = std::move(other.headersToInsert);
140 this->thisWorkerId.store(this->thisWorkerId.load());
141 this->relativePath = std::move(other.relativePath);
142 this->callStack = std::move(other.callStack);
143 this->workloadClass = other.workloadClass;
144 this->baseUrl = std::move(other.baseUrl);
145 this->content = std::move(other.content);
146 this->workloadType = other.workloadType;
147 this->payloadType = other.payloadType;
148 }
149 return *this;
150 }
151
152 HttpsWorkloadData::HttpsWorkloadData(HttpsWorkloadData&& other) noexcept {
153 *this = std::move(other);
154 }
155
156 HttpsWorkloadData& HttpsWorkloadData::operator=(HttpsWorkloadType type) noexcept {
157 if (!HttpsWorkloadData::workloadIdsExternal.contains(type)) {
158 std::unique_ptr<std::atomic_int64_t> integer{ std::make_unique<std::atomic_int64_t>() };
159 std::unique_ptr<std::atomic_int64_t> integer02{ std::make_unique<std::atomic_int64_t>() };
160 HttpsWorkloadData::workloadIdsExternal[type] = std::move(integer);
161 HttpsWorkloadData::workloadIdsInternal[type] = std::move(integer02);
162 }
163 this->thisWorkerId.store(HttpsWorkloadData::incrementAndGetWorkloadId(type));
164 this->workloadType = type;
165 return *this;
166 }
167
168 HttpsWorkloadData::HttpsWorkloadData(HttpsWorkloadType type) noexcept {
169 *this = type;
170 }
171
172 int64_t HttpsWorkloadData::incrementAndGetWorkloadId(HttpsWorkloadType workloadType) noexcept {
173 int64_t value{ HttpsWorkloadData::workloadIdsExternal[workloadType]->load() };
174 HttpsWorkloadData::workloadIdsExternal[workloadType]->store(value + 1);
175 return value;
176 }
177
178 std::unordered_map<HttpsWorkloadType, std::unique_ptr<std::atomic_int64_t>> HttpsWorkloadData::workloadIdsExternal{};
179 std::unordered_map<HttpsWorkloadType, std::unique_ptr<std::atomic_int64_t>> HttpsWorkloadData::workloadIdsInternal{};
180
181 HelloData::HelloData(simdjson::ondemand::value jsonObjectData) {
182 this->heartbeatInterval = DiscordCoreAPI::getUint64(jsonObjectData, "heartbeat_interval");
183 }
184
185 WebSocketMessage::WebSocketMessage(simdjson::ondemand::value jsonObjectData) {
186 this->op = DiscordCoreAPI::getUint32(jsonObjectData, "op");
187
188 this->s = DiscordCoreAPI::getUint32(jsonObjectData, "s");
189
190 this->t = DiscordCoreAPI::getString(jsonObjectData, "t");
191 }
192
193 InvalidSessionData::InvalidSessionData(simdjson::ondemand::value jsonObjectData) {
194 this->d = DiscordCoreAPI::getBool(jsonObjectData, "d");
195 }
196
197 ReadyData::ReadyData(simdjson::ondemand::value jsonObjectData) {
198 this->resumeGatewayUrl = DiscordCoreAPI::getString(jsonObjectData, "resume_gateway_url");
199 this->resumeGatewayUrl = this->resumeGatewayUrl.substr(this->resumeGatewayUrl.find("wss://") + std::string{ "wss://" }.size());
200 this->resumeGatewayUrl = this->resumeGatewayUrl.substr(0, this->resumeGatewayUrl.find("/"));
201
202 this->sessionId = DiscordCoreAPI::getString(jsonObjectData, "session_id");
203
204 this->v = DiscordCoreAPI::getUint32(jsonObjectData, "v");
205
206 simdjson::ondemand::value user{};
207 if (jsonObjectData["user"].get(user) == simdjson::error_code::SUCCESS) {
208 this->user = DiscordCoreAPI::UserData{ user };
209 }
210 }
211}
212
213namespace DiscordCoreAPI {
214
215 UpdatePresenceData::operator Jsonifier() {
216 Jsonifier data{};
217 data["op"] = 3;
218 for (auto& value: this->activities) {
219 Jsonifier dataNew{};
220 if (value.url != "") {
221 dataNew["url"] = std::string{ value.url };
222 }
223 dataNew["name"] = std::string{ value.name };
224 dataNew["type"] = value.type;
225 data["d"]["activities"].emplaceBack(dataNew);
226 }
227 switch (this->status) {
229 data["status"] = "online";
230 break;
231 }
233 data["status"] = "dnd";
234 break;
235 }
237 data["status"] = "invisible";
238 break;
239 }
241 data["status"] = "offline";
242 break;
243 }
245 data["status"] = "idle";
246 break;
247 }
248 }
249 if (this->since != 0) {
250 data["since"] = this->since;
251 }
252 data["afk"] = this->afk;
253 return data;
254 }
255
257 TimeStamp timeStamp{ (this->id.operator size_t() >> 22) + 1420070400000, timeFormat };
258 return timeStamp.operator std::string();
259 }
260
261 RoleTagsData::RoleTagsData(simdjson::ondemand::value jsonObjectData) {
262 this->botId = getString(jsonObjectData, "bot_id");
263
264 this->integrationId = getString(jsonObjectData, "integration_id");
265 }
266
267 UserData::UserData(simdjson::ondemand::value jsonObjectData) {
268 this->id = getId(jsonObjectData, "id");
269 if (this->id == 0) {
270 return;
271 }
272
273 int32_t newFlags{};
274 newFlags = setBool(newFlags, UserFlags::MFAEnabled, getBool(jsonObjectData, "mfa_enabled"));
275
276 newFlags = setBool(newFlags, UserFlags::Verified, getBool(jsonObjectData, "verified"));
277
278 newFlags = setBool(newFlags, UserFlags::System, getBool(jsonObjectData, "system"));
279
280 newFlags = setBool(newFlags, UserFlags::Bot, getBool(jsonObjectData, "bot"));
281
282 newFlags += getUint32(jsonObjectData, "public_flags");
283
284 newFlags = setBool(newFlags, this->flags, true);
285
286 this->flags = static_cast<UserFlags>(newFlags);
287
288 this->userName = getString(jsonObjectData, "username");
289
290 this->avatar = getString(jsonObjectData, "avatar");
291
292 this->discriminator = getString(jsonObjectData, "discriminator");
293 }
294
295 std::string UserData::getAvatarUrl() {
296 std::string stringNew{ "https://cdn.discordapp.com/" };
297 stringNew += "avatars/" + this->id + "/" + this->avatar.getIconHash();
298 return stringNew;
299 }
300
301 AttachmentData ::AttachmentData(simdjson::ondemand::value jsonObjectData) {
302 this->id = getId(jsonObjectData, "id");
303
304 this->filename = getString(jsonObjectData, "filename");
305
306 this->contentType = getString(jsonObjectData, "content_type");
307
308 this->ephemeral = getBool(jsonObjectData, "ephemeral");
309
310 this->description = getString(jsonObjectData, "description");
311
312 this->size = getUint32(jsonObjectData, "size");
313
314 this->url = getString(jsonObjectData, "url");
315
316 this->proxyUrl = getString(jsonObjectData, "proxy_url");
317
318 this->width = getUint32(jsonObjectData, "width");
319
320 this->height = getUint32(jsonObjectData, "height");
321 }
322
323 EmbedFooterData::EmbedFooterData(simdjson::ondemand::value jsonObjectData) {
324 this->text = getString(jsonObjectData, "text");
325
326 this->iconUrl = getString(jsonObjectData, "icon_url");
327
328 this->proxyIconUrl = getString(jsonObjectData, "proxy_icon_url");
329 }
330
331 EmbedImageData::EmbedImageData(simdjson::ondemand::value jsonObjectData) {
332 this->url = getString(jsonObjectData, "url");
333
334 this->proxyUrl = getString(jsonObjectData, "proxy_url");
335
336 this->width = getUint32(jsonObjectData, "width");
337
338 this->height = getUint32(jsonObjectData, "height");
339 }
340
341 EmbedThumbnailData::EmbedThumbnailData(simdjson::ondemand::value jsonObjectData) {
342 this->url = getString(jsonObjectData, "url");
343
344 this->proxyUrl = getString(jsonObjectData, "proxy_url");
345
346 this->width = getUint32(jsonObjectData, "width");
347
348 this->height = getUint32(jsonObjectData, "height");
349 }
350
351 EmbedVideoData::EmbedVideoData(simdjson::ondemand::value jsonObjectData) {
352 this->url = getString(jsonObjectData, "url");
353
354 this->proxyUrl = getString(jsonObjectData, "proxy_url");
355
356 this->width = getUint32(jsonObjectData, "width");
357
358 this->height = getUint32(jsonObjectData, "height");
359 }
360
361 EmbedProviderData::EmbedProviderData(simdjson::ondemand::value jsonObjectData) {
362 this->url = getString(jsonObjectData, "url");
363
364 this->name = getString(jsonObjectData, "name");
365 }
366
367 EmbedAuthorData::EmbedAuthorData(simdjson::ondemand::value jsonObjectData) {
368 this->url = getString(jsonObjectData, "url");
369
370 this->proxyIconUrl = getString(jsonObjectData, "proxy_icon_url");
371
372 this->name = getString(jsonObjectData, "name");
373
374 this->iconUrl = getString(jsonObjectData, "icon_url");
375 }
376
377 EmbedFieldData::EmbedFieldData(simdjson::ondemand::value jsonObjectData) {
378 this->Inline = getBool(jsonObjectData, "inline");
379
380 this->name = getString(jsonObjectData, "name");
381
382 this->value = getString(jsonObjectData, "value");
383 }
384
385 EmbedData::EmbedData(simdjson::ondemand::value jsonObjectData) {
386 this->title = getString(jsonObjectData, "title");
387
388 this->type = getString(jsonObjectData, "type");
389
390 this->description = getString(jsonObjectData, "description");
391
392 this->url = getString(jsonObjectData, "url");
393
394 this->timeStamp = getString(jsonObjectData, "timestamp");
395
396 this->hexColorValue = getUint32(jsonObjectData, "color");
397
398 simdjson::ondemand::value object{};
399 if (getObject(object, "footer", jsonObjectData)) {
400 EmbedFooterData data{ object };
401 this->footer = std::move(data);
402 }
403
404 if (getObject(object, "image", jsonObjectData)) {
405 EmbedImageData data{ object };
406 this->image = std::move(data);
407 }
408
409 if (getObject(object, "provider", jsonObjectData)) {
410 EmbedProviderData data{ object };
411 this->provider = std::move(data);
412 }
413
414 if (getObject(object, "thumbnail", jsonObjectData)) {
415 EmbedThumbnailData data{ object };
416 this->thumbnail = std::move(data);
417 }
418
419 if (getObject(object, "video", jsonObjectData)) {
420 EmbedVideoData data{ object };
421 this->video = std::move(data);
422 }
423
424 if (getObject(object, "author", jsonObjectData)) {
425 EmbedAuthorData data{ object };
426 this->author = std::move(data);
427 }
428
429 simdjson::ondemand::array arrayValue{};
430 if (getArray(arrayValue, "fields", jsonObjectData)) {
431 this->fields.clear();
432 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
433 EmbedFieldData newData{ value.value() };
434 this->fields.emplace_back(std::move(newData));
435 }
436 }
437 }
438
439 MessageReferenceData::MessageReferenceData(simdjson::ondemand::value jsonObjectData) {
440 this->messageId = getId(jsonObjectData, "message_id");
441
442 this->channelId = getId(jsonObjectData, "channel_id");
443
444 this->guildId = getId(jsonObjectData, "guild_id");
445
446 this->failIfNotExists = getBool(jsonObjectData, "fail_if_not_exists");
447 }
448
449 ThreadMetadataData::ThreadMetadataData(simdjson::ondemand::value jsonObjectData) {
450 this->archived = getBool(jsonObjectData, "archived");
451
452 this->invitable = getBool(jsonObjectData, "invitable");
453
454 this->autoArchiveDuration = getUint32(jsonObjectData, "auto_archive_duration");
455
456 this->archiveTimestamp = getString(jsonObjectData, "archive_timestamp");
457
458 this->locked = getBool(jsonObjectData, "locked");
459 }
460
461 ThreadMemberData::ThreadMemberData(simdjson::ondemand::value jsonObjectData) {
462 this->id = getId(jsonObjectData, "id");
463
464 this->userId = getId(jsonObjectData, "user_id");
465
466 this->joinTimestamp = getString(jsonObjectData, "join_timestamp");
467
468 this->flags = getUint32(jsonObjectData, "flags");
469 }
470
471 ThreadMemberDataVector::ThreadMemberDataVector(simdjson::ondemand::value jsonObjectData) {
472 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
473 simdjson::ondemand::array arrayValue{};
474 if (getArray(arrayValue, jsonObjectData)) {
475 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
476 ThreadMemberData newData{ value.value() };
477 this->threadMembers.emplace_back(std::move(newData));
478 }
479 }
480 }
481 }
482
483 VoiceStateDataLight::VoiceStateDataLight(simdjson::ondemand::value jsonObjectData) {
484 this->channelId = getId(jsonObjectData, "channel_id");
485
486 this->guildId = getId(jsonObjectData, "guild_id");
487
488 this->userId = getId(jsonObjectData, "user_id");
489 }
490
491 VoiceStateData::VoiceStateData(simdjson::ondemand::value jsonObjectData) {
492 this->requestToSpeakTimestamp = getString(jsonObjectData, "request_to_speak_timestamp");
493
494 this->channelId = getId(jsonObjectData, "channel_id");
495
496 this->guildId = getId(jsonObjectData, "guild_id");
497
498 this->selfStream = getBool(jsonObjectData, "self_stream");
499
500 this->userId = getId(jsonObjectData, "user_id");
501
502 this->selfVideo = getBool(jsonObjectData, "self_video");
503
504 this->sessionId = getString(jsonObjectData, "session_id");
505
506 this->selfDeaf = getBool(jsonObjectData, "self_deaf");
507
508 this->selfMute = getBool(jsonObjectData, "self_mute");
509
510 this->suppress = getBool(jsonObjectData, "suppress");
511
512 this->deaf = getBool(jsonObjectData, "deaf");
513
514 this->mute = getBool(jsonObjectData, "mute");
515 }
516
517 RoleData::RoleData(simdjson::ondemand::value jsonObjectData) {
518 this->id = getId(jsonObjectData, "id");
519
520 this->name = getString(jsonObjectData, "name");
521
522 std::stringstream stream{};
523 stream << getString(jsonObjectData, "unicode_emoji");
524 for (auto& value: stream.str()) {
525 this->unicodeEmoji.emplace_back(value);
526 }
527 if (this->unicodeEmoji.size() > 3) {
528 this->unicodeEmoji = static_cast<std::string>(this->unicodeEmoji).substr(1, this->unicodeEmoji.size() - 3);
529 }
530
531 this->guildId = getId(jsonObjectData, "guild_id");
532
533 this->color = getUint32(jsonObjectData, "color");
534
535 uint8_t newFlags{};
536 newFlags = setBool(newFlags, RoleFlags::Hoist, getBool(jsonObjectData, "hoist"));
537
538 newFlags = setBool(newFlags, RoleFlags::Managed, getBool(jsonObjectData, "managed"));
539
540 newFlags = setBool(newFlags, RoleFlags::Mentionable, getBool(jsonObjectData, "mentionable"));
541
542 this->flags = static_cast<RoleFlags>(newFlags);
543
544 this->position = getUint32(jsonObjectData, "position");
545
546 this->permissions = getString(jsonObjectData, "permissions");
547 }
548
549 EmojiData::EmojiData(simdjson::ondemand::value jsonObjectData) {
550 this->id = getId(jsonObjectData, "id");
551
552 this->name = getString(jsonObjectData, "name");
553
554 simdjson::ondemand::array arrayValue{};
555 if (getArray(arrayValue, "roles", jsonObjectData)) {
556 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
557 RoleData newData{ value.value() };
558 this->roles.emplace_back(std::move(newData));
559 }
560 }
561
562 simdjson::ondemand::value object{};
563 if (getObject(object, "user", jsonObjectData)) {
564 this->user = UserData{ object };
565 }
566
567 this->requireColons = getBool(jsonObjectData, "require_colons");
568
569 this->managed = getBool(jsonObjectData, "managed");
570
571 this->animated = getBool(jsonObjectData, "animated");
572
573 this->available = getBool(jsonObjectData, "available");
574 }
575
576 PresenceUpdateData::PresenceUpdateData(simdjson::ondemand::value jsonObjectData) {
577 this->guildId = getId(jsonObjectData, "guild_id");
578
579 auto stringNew = getString(jsonObjectData, "status");
580
581 if (stringNew == "online") {
582 uint8_t newFlags = setBool(uint8_t{}, PresenceUpdateFlags::Status_Online, true);
583 this->theStatus = static_cast<PresenceUpdateFlags>(newFlags);
584 } else if (stringNew == "idle") {
585 uint8_t newFlags = setBool(uint8_t{}, PresenceUpdateFlags::Status_Idle, true);
586 this->theStatus = static_cast<PresenceUpdateFlags>(newFlags);
587 } else if (stringNew == "dnd") {
588 uint8_t newFlags = setBool(uint8_t{}, PresenceUpdateFlags::Status_Dnd, true);
589 this->theStatus = static_cast<PresenceUpdateFlags>(newFlags);
590 }
591
592 parseObject(jsonObjectData, this->theStatus);
593 }
594
595 GuildMemberData& GuildMemberData::operator=(GuildMemberData&& other) noexcept {
596 if (this != &other) {
597 this->permissions = std::move(other.permissions);
598 this->joinedAt = std::move(other.joinedAt);
599 this->avatar = std::move(other.avatar);
600 this->roles = std::move(other.roles);
601 this->flags = std::move(other.flags);
602 this->nick = std::move(other.nick);
603 this->guildId = other.guildId;
604 this->id = other.id;
605 }
606 return *this;
607 }
608
609 GuildMemberData::GuildMemberData(GuildMemberData&& other) noexcept {
610 *this = std::move(other);
611 }
612
613 GuildMemberData& GuildMemberData::operator=(simdjson::ondemand::value jsonObjectData) {
614 uint8_t newFlags{};
615 newFlags = setBool(newFlags, GuildMemberFlags::Pending, getBool(jsonObjectData, "pending"));
616
617 newFlags = setBool(newFlags, GuildMemberFlags::Mute, getBool(jsonObjectData, "mute"));
618
619 newFlags = setBool(newFlags, GuildMemberFlags::Deaf, getBool(jsonObjectData, "deaf"));
620
621 this->flags = static_cast<GuildMemberFlags>(newFlags);
622
623 this->joinedAt = getString(jsonObjectData, "joined_at");
624
625 this->guildId = getId(jsonObjectData, "guild_id");
626
627 simdjson::ondemand::array arrayValue{};
628 if (getArray(arrayValue, "roles", jsonObjectData)) {
629 this->roles.clear();
630 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
631 this->roles.emplace_back(getId(value.value()));
632 }
633 }
634
635 this->permissions = getString(jsonObjectData, "permissions");
636
637 simdjson::ondemand::value object{};
638 if (getObject(object, "user", jsonObjectData)) {
639 UserData user{ object };
640 this->id = user.id;
641 Users::insertUser(std::move(user));
642 }
643
644 this->avatar = getString(jsonObjectData, "avatar");
645
646 newFlags += getUint8(jsonObjectData, "flags");
647
648 this->flags = static_cast<GuildMemberFlags>(newFlags);
649
650 this->nick = getString(jsonObjectData, "nick");
651 return *this;
652 }
653
654 GuildMemberData::GuildMemberData(simdjson::ondemand::value jsonObjectData) {
655 *this = jsonObjectData;
656 }
657
658 VoiceStateDataLight GuildMemberData::getVoiceStateData() {
659 VoiceStateDataLight dataToGet{};
660 dataToGet.guildId = this->guildId;
661 dataToGet.userId = this->id;
662 if (GuildMembers::getVsCache().contains(dataToGet)) {
663 return GuildMembers::getVsCache()[dataToGet];
664 } else {
665 return dataToGet;
666 }
667 }
668
669 std::string GuildMemberData::getAvatarUrl() {
670 if (this->avatar.getIconHash() != "") {
671 std::string stringNew{ "https://cdn.discordapp.com/" };
672 stringNew += "guilds/" + this->guildId + "/users/" + this->id + "/avatars/" + this->avatar.getIconHash();
673 return stringNew;
674 } else {
675 return this->getUserData().getAvatarUrl();
676 }
677 }
678
679 UserData GuildMemberData::getUserData() {
680 if (this->id.operator size_t() != 0) {
681 return Users::getCachedUser({ .userId = this->id });
682 } else {
683 return {};
684 }
685 }
686
687 OverWriteData::OverWriteData(simdjson::ondemand::value jsonObjectData) {
688 this->id = getId(jsonObjectData, "id");
689
690 this->allow = getUint64(jsonObjectData, "allow");
691
692 this->deny = getUint64(jsonObjectData, "deny");
693
694 this->type = static_cast<PermissionOverwritesType>(getUint8(jsonObjectData, "type"));
695 }
696
697 DefaultReactionData::DefaultReactionData(simdjson::ondemand::value jsonObjectData) {
698 this->emojiId = getId(jsonObjectData, "emoji_id");
699
700 this->emojiName = getString(jsonObjectData, "emoji_name");
701 }
702
703 ForumTagData::ForumTagData(simdjson::ondemand::value jsonObjectData) {
704 this->emojiId = getId(jsonObjectData, "emoji_id");
705
706 this->emojiName = getString(jsonObjectData, "emoji_name");
707
708 this->id = getId(jsonObjectData, "id");
709
710 this->moderated = getBool(jsonObjectData, "moderated");
711
712 this->name = getString(jsonObjectData, "name");
713 }
714
715 ChannelData::ChannelData(simdjson::ondemand::value jsonObjectData) {
716 uint8_t newFlags{};
717 newFlags = setBool(newFlags, ChannelFlags::NSFW, getBool(jsonObjectData, "nsfw"));
718
719 this->type = static_cast<ChannelType>(getUint8(jsonObjectData, "type"));
720
721 this->defaultSortOrder = static_cast<SortOrderTypes>(getUint8(jsonObjectData, "default_sort_order"));
722
723 this->memberCount = getUint32(jsonObjectData, "member_count");
724
725 this->ownerId = getId(jsonObjectData, "owner_id");
726
727 this->id = getId(jsonObjectData, "id");
728
729 newFlags += getUint8(jsonObjectData, "flags");
730
731 this->flags = static_cast<ChannelFlags>(newFlags);
732
733 this->parentId = getId(jsonObjectData, "parent_id");
734
735 this->guildId = getId(jsonObjectData, "guild_id");
736
737 this->position = getUint32(jsonObjectData, "position");
738
739 simdjson::ondemand::array arrayValue{};
740 if (getArray(arrayValue, "permission_overwrites", jsonObjectData)) {
741 this->permissionOverwrites.clear();
742 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
743 OverWriteData dataNew{ value.value() };
744 this->permissionOverwrites.emplace_back(std::move(dataNew));
745 }
746 }
747
748 this->name = getString(jsonObjectData, "name");
749 }
750
751 ActiveThreadsData::ActiveThreadsData(simdjson::ondemand::value jsonObjectData) {
752 simdjson::ondemand::array arrayValue{};
753 if (getArray(arrayValue, "threads", jsonObjectData)) {
754 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
755 ChannelData newData{ value.value() };
756 this->threads.emplace_back(std::move(newData));
757 }
758 }
759
760 if (getArray(arrayValue, "members", jsonObjectData)) {
761 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
762 ThreadMemberData newData{ value.value() };
763 this->members.emplace_back(std::move(newData));
764 }
765 }
766
767 this->hasMore = getBool(jsonObjectData, "has_more");
768 }
769
770 ArchivedThreadsData::ArchivedThreadsData(simdjson::ondemand::value jsonObjectData) {
771 simdjson::ondemand::array arrayValue{};
772
773 if (getArray(arrayValue, "threads", jsonObjectData)) {
774 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
775 ChannelData newData{ value.value() };
776 this->threads.emplace_back(std::move(newData));
777 }
778 }
779
780 ;
781 if (getArray(arrayValue, "members", jsonObjectData)) {
782 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
783 ThreadMemberData newData{ value.value() };
784 this->members.emplace_back(std::move(newData));
785 }
786 }
787
788 this->hasMore = getBool(jsonObjectData, "has_more");
789 }
790
791 TriggerMetaData::TriggerMetaData(simdjson::ondemand::value jsonObjectData) {
792 simdjson::ondemand::array arrayValue{};
793
794 if (getArray(arrayValue, "keyword_filter", jsonObjectData)) {
795 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
796 this->keywordFilter.emplace_back(value.get_string().value().data());
797 }
798 }
799
800 if (getArray(arrayValue, "presets", jsonObjectData)) {
801 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
802 this->presets.emplace_back(static_cast<KeywordPresetType>(value.get_uint64().value()));
803 }
804 }
805
806 if (getArray(arrayValue, "allow_list", jsonObjectData)) {
807 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
808 this->allowList.emplace_back(value.get_string().value());
809 }
810 }
811
812 this->mentionTotalLimit = getUint32(jsonObjectData, "mention_total_limit");
813 }
814
815 ActionMetaData::ActionMetaData(simdjson::ondemand::value jsonObjectData) {
816 this->channelId = getId(jsonObjectData, "channel_id");
817
818 this->durationSeconds = getUint64(jsonObjectData, "duration_seconds");
819 }
820
821 ActionData::ActionData(simdjson::ondemand::value jsonObjectData) {
822 simdjson::ondemand::value object{};
823 if (getObject(object, "metadata", jsonObjectData)) {
824 this->metadata = ActionMetaData{ object };
825 }
826
827 this->type = static_cast<ActionType>(getUint64(jsonObjectData, "type"));
828 }
829
830 AutoModerationRuleData::AutoModerationRuleData(simdjson::ondemand::value jsonObjectData) {
831 this->name = getString(jsonObjectData, "name");
832
833 this->id = getId(jsonObjectData, "id");
834
835 this->enabled = getBool(jsonObjectData, "enabled");
836
837 this->triggerType = static_cast<TriggerType>(getUint8(jsonObjectData, "trigger_type"));
838
839 this->eventType = static_cast<EventType>(getUint8(jsonObjectData, "event_type"));
840
841 this->creatorId = getId(jsonObjectData, "creator_id");
842
843 simdjson::ondemand::array arrayValue{};
844 if (getArray(arrayValue, "actions", jsonObjectData)) {
845 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
846 ActionData newData{ value.value() };
847 this->actions.emplace_back(std::move(newData));
848 }
849 }
850
851 if (getArray(arrayValue, "exempt_roles", jsonObjectData)) {
852 this->exemptRoles.clear();
853 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
854 this->exemptRoles.emplace_back(strtoull(std::string{ value.get_string().take_value() }));
855 }
856 }
857
858 if (getArray(arrayValue, "exempt_channels", jsonObjectData)) {
859 this->exemptChannels.clear();
860 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
861 this->exemptChannels.emplace_back(strtoull(std::string{ value.get_string().take_value() }));
862 }
863 }
864
865 simdjson::ondemand::value object{};
866 if (getObject(object, "trigger_metadata", jsonObjectData)) {
867 this->triggerMetaData = TriggerMetaData{ object };
868 }
869
870 this->guildId = getId(jsonObjectData, "guild_id");
871 }
872
873 ApplicationCommandPermissionData::ApplicationCommandPermissionData(simdjson::ondemand::value jsonObjectData) {
874 this->id = getId(jsonObjectData, "id");
875
876 this->permission = getBool(jsonObjectData, "permission");
877
878 this->type = static_cast<ApplicationCommandPermissionType>(getUint8(jsonObjectData, "type"));
879 }
880
881 GuildApplicationCommandPermissionsData::GuildApplicationCommandPermissionsData(simdjson::ondemand::value jsonObjectData) {
882 this->guildId = getId(jsonObjectData, "guild_id");
883
884 this->applicationId = getId(jsonObjectData, "application_id");
885
886 this->id = getId(jsonObjectData, "id");
887
888 simdjson::ondemand::array arrayValue{};
889 if (getArray(arrayValue, "permissions", jsonObjectData)) {
890 this->permissions.clear();
891 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
892 ApplicationCommandPermissionData newData{ value.value() };
893 this->permissions.emplace_back(std::move(newData));
894 }
895 }
896 }
897
898 GuildApplicationCommandPermissionsDataVector::GuildApplicationCommandPermissionsDataVector(simdjson::ondemand::value jsonObjectData) {
899 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
900 simdjson::ondemand::array arrayValue{};
901 if (getArray(arrayValue, jsonObjectData)) {
902 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
903 GuildApplicationCommandPermissionsData newData{ value.value() };
904 this->guildApplicationCommandPermissionss.emplace_back(std::move(newData));
905 }
906 }
907 }
908 }
909
910 EmojiDataVector::EmojiDataVector(simdjson::ondemand::value jsonObjectData) {
911 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
912 simdjson::ondemand::array arrayValue{};
913 if (getArray(arrayValue, jsonObjectData)) {
914 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
915 EmojiData newData{ value.value() };
916 this->theEmojis.emplace_back(std::move(newData));
917 }
918 }
919 }
920 }
921
922 ReactionData::ReactionData(simdjson::ondemand::value jsonObjectData) {
923 this->count = getUint32(jsonObjectData, "count");
924
925 this->me = getBool(jsonObjectData, "me");
926
927 simdjson::ondemand::value object{};
928 if (getObject(object, "emoji", jsonObjectData)) {
929 this->emoji = EmojiData{ object };
930 }
931
932 this->guildId = getId(jsonObjectData, "guild_id");
933
934 this->channelId = getId(jsonObjectData, "channel_id");
935
936 this->userId = getId(jsonObjectData, "user_id");
937
938 this->messageId = getId(jsonObjectData, "message_id");
939
940 if (getObject(object, "member", jsonObjectData)) {
941 this->member = GuildMemberData{ object };
942 }
943 }
944
945 VoiceRegionData::VoiceRegionData(simdjson::ondemand::value jsonObjectData) {
946 this->id = getId(jsonObjectData, "id");
947
948 this->custom = getBool(jsonObjectData, "custom");
949
950 this->deprecated = getBool(jsonObjectData, "deprecated");
951
952 this->optimal = getBool(jsonObjectData, "optimal");
953
954 this->name = getString(jsonObjectData, "name");
955 }
956
957 VoiceRegionDataVector::VoiceRegionDataVector(simdjson::ondemand::value jsonObjectData) {
958 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
959 simdjson::ondemand::array arrayValue{};
960 if (getArray(arrayValue, jsonObjectData)) {
961 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
962 VoiceRegionData newData{ value.value() };
963 this->voiceRegions.emplace_back(std::move(newData));
964 }
965 }
966 }
967 }
968
969 MessageActivityData::MessageActivityData(simdjson::ondemand::value jsonObjectData) {
970 this->type = static_cast<MessageActivityType>(getUint8(jsonObjectData, "type"));
971
972 this->partyId = getString(jsonObjectData, "party_id");
973 }
974
975 BanData::BanData(simdjson::ondemand::value jsonObjectData) {
976 simdjson::ondemand::value object{};
977 if (getObject(object, "user", jsonObjectData)) {
978 this->user = UserData{ object };
979 }
980
981 this->reason = getString(jsonObjectData, "reason");
982 }
983
984 BanDataVector::BanDataVector(simdjson::ondemand::value jsonObjectData) {
985 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
986 simdjson::ondemand::array arrayValue{};
987 if (getArray(arrayValue, jsonObjectData)) {
988 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
989 BanData newData{ value.value() };
990 this->bans.emplace_back(std::move(newData));
991 }
992 }
993 }
994 }
995
996 TeamMembersObjectData::TeamMembersObjectData(simdjson::ondemand::value jsonObjectData) {
997 this->membershipState = getUint32(jsonObjectData, "membership_state");
998
999 this->teamId = getId(jsonObjectData, "team_id");
1000
1001 simdjson::ondemand::array arrayValue{};
1002 if (getArray(arrayValue, "permissions", jsonObjectData)) {
1003 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1004 this->permissions.emplace_back(Permissions{ value.get_string().value().data() });
1005 }
1006 }
1007
1008 simdjson::ondemand::value object{};
1009 if (getObject(object, "user", jsonObjectData)) {
1010 this->user = UserData{ object };
1011 }
1012 }
1013
1014 TeamObjectData::TeamObjectData(simdjson::ondemand::value jsonObjectData) {
1015 this->icon = getString(jsonObjectData, "icon");
1016
1017 this->id = getId(jsonObjectData, "id");
1018
1019 simdjson::ondemand::array arrayValue{};
1020 if (getArray(arrayValue, "members", jsonObjectData)) {
1021 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1022 TeamMembersObjectData newData{ value.value() };
1023 this->members.emplace_back(std::move(newData));
1024 }
1025 }
1026
1027 this->ownerUserId = getId(jsonObjectData, "owner_user_id");
1028 }
1029
1030 InstallParamsData::InstallParamsData(simdjson::ondemand::value jsonObjectData) {
1031 simdjson::ondemand::array arrayValue{};
1032 if (getArray(arrayValue, "scopes", jsonObjectData)) {
1033 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1034 this->scopes.emplace_back(Permissions{ value.get_string().value().data() });
1035 }
1036 }
1037
1038 this->permissions = getString(jsonObjectData, "name");
1039 }
1040
1041 ApplicationData::ApplicationData(simdjson::ondemand::value jsonObjectData) {
1042 simdjson::ondemand::value object{};
1043 if (getObject(object, "params", jsonObjectData)) {
1044 this->params = InstallParamsData{ object };
1045 }
1046
1047 simdjson::ondemand::array arrayValue{};
1048 if (getArray(arrayValue, "tags", jsonObjectData)) {
1049 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1050 this->tags.emplace_back(value.get_string().value().data());
1051 }
1052 }
1053
1054 this->id = getId(jsonObjectData, "id");
1055
1056 this->name = getString(jsonObjectData, "name");
1057
1058 this->icon = getString(jsonObjectData, "icon");
1059
1060 this->description = getString(jsonObjectData, "description");
1061
1062 if (getArray(arrayValue, "rpc_origins", jsonObjectData)) {
1063 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1064 this->rpcOrigins.emplace_back(value.get_string().value().data());
1065 }
1066 }
1067
1068 this->botPublic = getBool(jsonObjectData, "bot_public");
1069
1070 this->botRequireCodeGrant = getBool(jsonObjectData, "bot_require_code_grant");
1071
1072 this->termsOfServiceUrl = getString(jsonObjectData, "terms_of_service_url");
1073
1074 this->privacyPolicyUrl = getString(jsonObjectData, "privacy_policy_url");
1075
1076 if (getObject(object, "owner", jsonObjectData)) {
1077 this->owner = UserData{ object };
1078 }
1079
1080 if (getObject(object, "team", jsonObjectData)) {
1081 this->team = TeamObjectData{ object };
1082 }
1083
1084 this->summary = getString(jsonObjectData, "summary");
1085
1086 this->verifyKey = getString(jsonObjectData, "verify_key");
1087
1088 this->guildId = getId(jsonObjectData, "guild_id");
1089
1090 this->primarySkuId = getString(jsonObjectData, "primary_sku_id");
1091
1092 this->slug = getString(jsonObjectData, "slug");
1093
1094 this->coverImage = getString(jsonObjectData, "cover_image");
1095
1096 this->flags = static_cast<ApplicationFlags>(getUint8(jsonObjectData, "flags"));
1097 }
1098
1099 AuthorizationInfoData::AuthorizationInfoData(simdjson::ondemand::value jsonObjectData) {
1100 simdjson::ondemand::value object{};
1101 if (getObject(object, "application", jsonObjectData)) {
1102 this->application = ApplicationData{ object };
1103 }
1104
1105 simdjson::ondemand::array arrayValue{};
1106 if (getArray(arrayValue, "features", jsonObjectData)) {
1107 this->scopes.clear();
1108 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1109 this->scopes.emplace_back(std::string{ value.get_string().take_value() });
1110 }
1111 }
1112
1113 this->expires = getString(jsonObjectData, "expires");
1114 if (getObject(object, "user", jsonObjectData)) {
1115 this->user = UserData{ object };
1116 }
1117 }
1118
1119 AccountData::AccountData(simdjson::ondemand::value jsonObjectData) {
1120 this->id = getId(jsonObjectData, "id");
1121
1122 this->name = getString(jsonObjectData, "name");
1123 }
1124
1125 GuildWidgetData::GuildWidgetData(simdjson::ondemand::value jsonObjectData) {
1126 this->enabled = getBool(jsonObjectData, "enabled");
1127
1128 this->channelId = getId(jsonObjectData, "channel_id");
1129 };
1130
1131 GuildWidgetImageData::GuildWidgetImageData(simdjson::ondemand::value jsonObjectData) {
1132 this->url = getString(jsonObjectData, "widget_image");
1133 }
1134
1135 IntegrationData::IntegrationData(simdjson::ondemand::value jsonObjectData) {
1136 this->id = getId(jsonObjectData, "id");
1137
1138 this->name = getString(jsonObjectData, "name");
1139
1140 this->type = getString(jsonObjectData, "type");
1141
1142 this->enabled = getBool(jsonObjectData, "enabled");
1143
1144 this->syncing = getBool(jsonObjectData, "syncing");
1145
1146 this->roleId = getId(jsonObjectData, "role_id");
1147
1148 this->enableEmoticons = getBool(jsonObjectData, "enable_emoticons");
1149
1150 this->expireBehavior = getUint32(jsonObjectData, "expire_behavior");
1151
1152 this->expireGracePeriod = getUint32(jsonObjectData, "expire_grace_period");
1153
1154 simdjson::ondemand::value object{};
1155 if (getObject(object, "user", jsonObjectData)) {
1156 this->user = UserData{ object };
1157 }
1158
1159 if (getObject(object, "account", jsonObjectData)) {
1160 this->account = AccountData{ object };
1161 }
1162
1163 if (getObject(object, "application", jsonObjectData)) {
1164 this->application = ApplicationData{ object };
1165 }
1166
1167 this->syncedAt = getString(jsonObjectData, "synced_at");
1168
1169 this->subscriberCount = getUint32(jsonObjectData, "subscriber_count");
1170
1171 this->revoked = getBool(jsonObjectData, "revoked");
1172 }
1173
1174 IntegrationDataVector::IntegrationDataVector(simdjson::ondemand::value jsonObjectData) {
1175 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
1176 simdjson::ondemand::array arrayValue{};
1177 if (getArray(arrayValue, jsonObjectData)) {
1178 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1179 IntegrationData newData{ value.value() };
1180 this->integeregrations.emplace_back(std::move(newData));
1181 }
1182 }
1183 }
1184 }
1185
1186 OptionalAuditEntryInfoData::OptionalAuditEntryInfoData(simdjson::ondemand::value jsonObjectData) {
1187 this->deleteMemberDays = getString(jsonObjectData, "delete_member_days");
1188
1189 this->membersRemoved = getString(jsonObjectData, "members_removed");
1190
1191 this->channelId = getId(jsonObjectData, "channel_id");
1192
1193 this->messageId = getId(jsonObjectData, "message_id");
1194
1195 this->count = getString(jsonObjectData, "count");
1196
1197 this->id = getId(jsonObjectData, "id");
1198
1199 this->type = getString(jsonObjectData, "type");
1200
1201 this->roleName = getString(jsonObjectData, "role_name");
1202 }
1203
1204 AuditLogChangeData::AuditLogChangeData(simdjson::ondemand::value jsonObjectData) {
1205 this->newValue.value = getString(jsonObjectData, "new_value");
1206
1207 this->oldValue.value = getString(jsonObjectData, "old_value");
1208
1209 this->key = getString(jsonObjectData, "key");
1210 }
1211
1212 GuildPruneCountData::GuildPruneCountData(simdjson::ondemand::value jsonObjectData) {
1213 this->count = getUint32(jsonObjectData, "pruned");
1214 }
1215
1216 AuditLogEntryData::AuditLogEntryData(simdjson::ondemand::value jsonObjectData) {
1217 this->targetId = getId(jsonObjectData, "target_id");
1218
1219 simdjson::ondemand::array arrayValue{};
1220 if (getArray(arrayValue, "changes", jsonObjectData)) {
1221 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1222 AuditLogChangeData newData{ value.value() };
1223 this->changes.emplace_back(std::move(newData));
1224 }
1225 }
1226
1227 this->userId = getId(jsonObjectData, "user_id");
1228
1229 this->id = getId(jsonObjectData, "id");
1231
1232 this->actionType = static_cast<AuditLogEvent>(getUint16(jsonObjectData, "action_type"));
1233
1234 simdjson::ondemand::value object{};
1235 if (getObject(object, "options", jsonObjectData)) {
1236 this->options = OptionalAuditEntryInfoData{ object };
1237 }
1238
1239 this->reason = getString(jsonObjectData, "reason");
1240 }
1241
1242 WelcomeScreenChannelData::WelcomeScreenChannelData(simdjson::ondemand::value jsonObjectData) {
1243 this->channelId = getId(jsonObjectData, "channel_id");
1244
1245 this->description = getString(jsonObjectData, "description");
1246
1247 this->emojiId = getId(jsonObjectData, "emoji_id");
1248
1249 this->emojiName = getString(jsonObjectData, "emoji_name");
1250 }
1251
1252 WelcomeScreenData::WelcomeScreenData(simdjson::ondemand::value jsonObjectData) {
1253 this->description = getString(jsonObjectData, "description");
1254
1255 simdjson::ondemand::array arrayValue{};
1256 if (getArray(arrayValue, "welcome_channels", jsonObjectData)) {
1257 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1258 WelcomeScreenChannelData newData{ value.value() };
1259 this->welcomeChannels.emplace_back(std::move(newData));
1260 }
1261 }
1262 }
1263
1264 StageInstanceData::StageInstanceData(simdjson::ondemand::value jsonObjectData) {
1265 this->id = getId(jsonObjectData, "id");
1266
1267 this->guildId = getId(jsonObjectData, "guild_id");
1268
1269 this->channelId = getId(jsonObjectData, "channel_id");
1270
1271 this->topic = getString(jsonObjectData, "topic");
1272
1273 this->privacyLevel = static_cast<StageInstancePrivacyLevel>(getUint8(jsonObjectData, "privacy_level"));
1274
1275 this->discoverableDisabled = getBool(jsonObjectData, "discoverable_disabled");
1276 }
1277
1278 StickerData::StickerData(simdjson::ondemand::value jsonObjectData) {
1279 this->asset = getString(jsonObjectData, "asset");
1280
1281 this->description = getString(jsonObjectData, "description");
1282
1283 this->formatType = static_cast<StickerFormatType>(getUint8(jsonObjectData, "format_type"));
1284
1285 uint8_t newFlags{};
1286 newFlags = setBool(newFlags, StickerFlags::Available, getBool(jsonObjectData, "available"));
1287
1288 this->flags = static_cast<StickerFlags>(newFlags);
1289
1290 this->guildId = getId(jsonObjectData, "guild_id");
1291
1292 this->id = getId(jsonObjectData, "id");
1293
1294 this->packId = getString(jsonObjectData, "pack_id");
1295
1296 this->type = static_cast<StickerType>(getUint8(jsonObjectData, "type"));
1297
1298 this->sortValue = getUint32(jsonObjectData, "sort_value");
1299
1300 this->name = getString(jsonObjectData, "name");
1301
1302 simdjson::ondemand::value object{};
1303 if (getObject(object, "user", jsonObjectData)) {
1304 this->user = UserData{ object };
1305 }
1306 }
1307
1308 GuildPreviewData::GuildPreviewData(simdjson::ondemand::value jsonObjectData) {
1309 this->approximatePresenceCount = getUint32(jsonObjectData, "approximate_presence_count");
1310
1311 this->approximateMemberCount = getUint32(jsonObjectData, "approximate_member_count");
1312
1313 this->discoverySplash = getString(jsonObjectData, "discovery_splash");
1314
1315 simdjson::ondemand::array arrayValue{};
1316 if (getArray(arrayValue, "emojis", jsonObjectData)) {
1317 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1318 EmojiData newData{ value.value() };
1319 this->emojis.emplace_back(std::move(newData));
1320 }
1321 }
1322
1323 if (getArray(arrayValue, "stickers", jsonObjectData)) {
1324 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1325 StickerData newData{ value.value() };
1326 this->stickers.emplace_back(std::move(newData));
1327 }
1328 }
1329
1330 if (getArray(arrayValue, "features", jsonObjectData)) {
1331 this->features.clear();
1332 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1333 this->features.emplace_back(value.get_string().take_value());
1334 }
1335 }
1336
1337 this->description = getString(jsonObjectData, "description");
1338
1339 this->splash = getString(jsonObjectData, "splash");
1340
1341 this->icon = getString(jsonObjectData, "icon");
1342
1343 this->name = getString(jsonObjectData, "name");
1344
1345 this->id = getId(jsonObjectData, "id");
1346 }
1347
1348 VoiceConnection* GuildData::connectToVoice(const Snowflake guildMemberId, const Snowflake channelId, bool selfDeaf, bool selfMute,
1349 StreamInfo streamInfoNew) {
1350 if (DiscordCoreClient::getVoiceConnection(this->id) && DiscordCoreClient::getVoiceConnection(this->id)->areWeConnected()) {
1351 this->voiceConnectionPtr = DiscordCoreClient::getVoiceConnection(this->id);
1352 return this->voiceConnectionPtr;
1353 } else if (static_cast<Snowflake>(guildMemberId) != 0 || static_cast<Snowflake>(channelId) != 0) {
1354 Snowflake channelId{};
1355 if (static_cast<Snowflake>(guildMemberId) != 0) {
1356 VoiceStateDataLight dataLight{};
1357 dataLight.guildId = this->id;
1358 dataLight.userId = guildMemberId;
1359 auto voiceStateData = GuildMembers::getVsCache()[dataLight];
1360 if (voiceStateData.channelId != 0) {
1361 channelId = voiceStateData.channelId;
1362 }
1363 } else {
1364 channelId = channelId;
1365 }
1366 uint64_t theShardId{ (this->id.operator size_t() >> 22) % this->discordCoreClient->configManager.getTotalShardCount() };
1367 auto theBaseSocketAgentIndex{ static_cast<int32_t>(
1368 floor(static_cast<double>(theShardId) / static_cast<double>(this->discordCoreClient->configManager.getTotalShardCount()) *
1369 this->discordCoreClient->baseSocketAgentsMap.size())) };
1370 VoiceConnectInitData voiceConnectInitData{};
1371 voiceConnectInitData.currentShard = theShardId;
1372 voiceConnectInitData.streamInfo = streamInfoNew;
1373 voiceConnectInitData.channelId = channelId;
1374 voiceConnectInitData.guildId = this->id;
1375 voiceConnectInitData.userId = this->discordCoreClient->getBotUser().id;
1376 voiceConnectInitData.selfDeaf = selfDeaf;
1377 voiceConnectInitData.selfMute = selfMute;
1378 StopWatch stopWatch{ 10000ms };
1379 auto voiceConnection = DiscordCoreClient::getVoiceConnection(this->id);
1380 voiceConnection->connect(voiceConnectInitData);
1381 while (voiceConnection->areWeConnected()) {
1382 std::this_thread::sleep_for(1ms);
1383 }
1384 this->voiceConnectionPtr = voiceConnection;
1385 return this->voiceConnectionPtr;
1386 } else {
1387 return nullptr;
1388 }
1389 }
1390
1391 std::string GuildData::getIconUrl() noexcept {
1392 std::string stringNew{ "https://cdn.discordapp.com/" };
1393 stringNew += "icons/" + this->id + "/" + this->icon.getIconHash() + ".png";
1394 return stringNew;
1395 }
1396
1397 bool GuildData::areWeConnected() {
1398 return DiscordCoreClient::getVoiceConnection(this->id)->areWeConnected();
1399 }
1400
1401 void GuildData::disconnect() {
1402 if (DiscordCoreClient::getVoiceConnection(this->id)) {
1403 UpdateVoiceStateData updateVoiceData{};
1404 updateVoiceData.channelId = 0;
1405 updateVoiceData.selfDeaf = false;
1406 updateVoiceData.selfMute = false;
1407 updateVoiceData.guildId = this->id;
1408 this->discordCoreClient->getBotUser().updateVoiceStatus(updateVoiceData);
1409 DiscordCoreClient::getVoiceConnection(this->id)->disconnect();
1410 this->voiceConnectionPtr = nullptr;
1411 }
1412 }
1413
1414 GuildData::GuildData(simdjson::ondemand::value jsonObjectData) {
1415 uint8_t newFlags{};
1416 newFlags = setBool(newFlags, GuildFlags::WidgetEnabled, getBool(jsonObjectData, "widget_enabled"));
1417
1418 newFlags = setBool(newFlags, GuildFlags::Unavailable, getBool(jsonObjectData, "unavailable"));
1419
1420 newFlags = setBool(newFlags, GuildFlags::Owner, getBool(jsonObjectData, "owner"));
1421
1422 newFlags = setBool(newFlags, GuildFlags::Large, getUint8(jsonObjectData, "large"));
1423
1424 this->flags = static_cast<GuildFlags>(newFlags);
1425
1426 this->ownerId = getId(jsonObjectData, "owner_id");
1427
1428 this->memberCount = getUint32(jsonObjectData, "member_count");
1429
1430 this->joinedAt = getString(jsonObjectData, "joined_at");
1431
1432 this->id = getId(jsonObjectData, "id");
1433
1434 this->icon = getString(jsonObjectData, "icon");
1435
1436 this->name = getString(jsonObjectData, "name");
1437
1438 this->threads.clear();
1439
1440 simdjson::ondemand::array arrayValue{};
1441 if (getArray(arrayValue, "features", jsonObjectData)) {
1442 this->threads.clear();
1443 for (auto value: arrayValue) {
1444 auto& object = value.value();
1445 this->threads.emplace_back(getId(object, "id"));
1446 }
1447 }
1448
1449 if (getArray(arrayValue, "stickers", jsonObjectData)) {
1450 this->stickers.clear();
1451 for (auto value: arrayValue) {
1452 this->stickers.emplace_back(getId(value.value(), "id"));
1453 }
1454 }
1455
1456 if (getArray(arrayValue, "guild_scheduled_events", jsonObjectData)) {
1457 this->guildScheduledEvents.clear();
1458 for (auto value: arrayValue) {
1459 this->guildScheduledEvents.emplace_back(getId(value.value(), "id"));
1460 }
1461 }
1462
1463 if (getArray(arrayValue, "stage_instances", jsonObjectData)) {
1464 this->stageInstances.clear();
1465 for (auto value: arrayValue) {
1466 this->stageInstances.emplace_back(getId(value.value(), "id"));
1467 }
1468 }
1469
1470 if (getArray(arrayValue, "emoji", jsonObjectData)) {
1471 this->emoji.clear();
1472 for (auto value: arrayValue) {
1473 this->emoji.emplace_back(getId(value.value(), "id"));
1474 }
1475 }
1476
1477 if (Roles::doWeCacheRoles()) {
1478 this->roles.clear();
1479 if (getArray(arrayValue, "roles", jsonObjectData)) {
1480 for (auto value: arrayValue) {
1481 RoleData newData{ value.value() };
1482 newData.guildId = this->id;
1483 this->roles.emplace_back(newData.id);
1484 Roles::insertRole(std::move(newData));
1485 }
1486 }
1487 }
1488
1489 if (GuildMembers::doWeCacheGuildMembers()) {
1490 this->members.clear();
1491 GuildMemberData newData{};
1492 if (getArray(arrayValue, "members", jsonObjectData)) {
1493 for (auto value: arrayValue) {
1494 newData = value.value();
1495 newData.guildId = this->id;
1496 this->members.emplace_back(newData.id);
1497 GuildMembers::insertGuildMember(std::move(newData));
1498 }
1499 }
1500 }
1501
1502 if (getArray(arrayValue, "voice_states", jsonObjectData)) {
1503 for (auto value: arrayValue) {
1504 VoiceStateDataLight dataNew{ value.value() };
1505 dataNew.guildId = this->id;
1506 GuildMembers::vsCache[dataNew] = dataNew;
1507 }
1508 }
1509
1510 if (GuildMembers::doWeCacheGuildMembers()) {
1511 this->presences.clear();
1512 if (getArray(arrayValue, "presences", jsonObjectData)) {
1513 for (auto value: arrayValue) {
1514 PresenceUpdateData newData{ value.value() };
1515 newData.guildId = this->id;
1516 this->presences.emplace_back(std::move(newData));
1517 }
1518 }
1519 }
1520
1521 if (Channels::doWeCacheChannels()) {
1522 this->channels.clear();
1523 if (getArray(arrayValue, "channels", jsonObjectData)) {
1524 for (auto value: arrayValue) {
1525 ChannelData newData{ value.value() };
1526 newData.guildId = this->id;
1527 this->channels.emplace_back(newData.id);
1528 Channels::insertChannel(std::move(newData));
1529 }
1530 }
1531 }
1532 }
1533
1534 GuildDataVector::GuildDataVector(simdjson::ondemand::value jsonObjectData) {
1535 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
1536 simdjson::ondemand::array arrayValue{};
1537 if (getArray(arrayValue, jsonObjectData)) {
1538 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1539 GuildData newData{ value.value() };
1540 this->guilds.emplace_back(std::move(newData));
1541 }
1542 }
1543 }
1544 }
1545
1546 GuildScheduledEventMetadata::GuildScheduledEventMetadata(simdjson::ondemand::value jsonObjectData) {
1547 this->location = getString(jsonObjectData, "location");
1548 }
1549
1550 GuildScheduledEventData::GuildScheduledEventData(simdjson::ondemand::value jsonObjectData) {
1551 this->privacyLevel = static_cast<GuildScheduledEventPrivacyLevel>(getUint8(jsonObjectData, "privacy_level"));
1552
1553 this->entityType = static_cast<GuildScheduledEventEntityType>(getUint8(jsonObjectData, "entity_type"));
1554
1555 this->status = static_cast<GuildScheduledEventStatus>(getUint8(jsonObjectData, "status"));
1556
1557 simdjson::ondemand::value object{};
1558 if (getObject(object, "entity_metadata", jsonObjectData)) {
1559 this->entityMetadata = GuildScheduledEventMetadata{ object };
1560 }
1561
1562 this->scheduledStartTime = getString(jsonObjectData, "scheduled_start_time");
1563
1564 this->scheduledEndTime = getString(jsonObjectData, "scheduled_end_time");
1565
1566 this->userCount = getUint32(jsonObjectData, "user_count");
1567
1568 this->channelId = getId(jsonObjectData, "channel_id");
1569
1570 this->creatorId = getId(jsonObjectData, "creator_id");
1571
1572 this->entityId = getId(jsonObjectData, "entity_id");
1573
1574 this->guildId = getId(jsonObjectData, "guild_id");
1575
1576 this->id = getId(jsonObjectData, "id");
1577
1578 this->description = getString(jsonObjectData, "description");
1579
1580 if (getObject(object, "creator", jsonObjectData)) {
1581 this->creator = UserData{ object };
1582 }
1583
1584 this->name = getString(jsonObjectData, "name");
1585 }
1586
1587 GuildScheduledEventUserData::GuildScheduledEventUserData(simdjson::ondemand::value jsonObjectData) {
1588 this->guildScheduledEventId = getId(jsonObjectData, "guild_scheduled_event_id");
1589
1590 simdjson::ondemand::value object{};
1591 if (getObject(object, "member", jsonObjectData)) {
1592 this->member = GuildMemberData{ object };
1593 }
1594
1595 if (getObject(object, "user", jsonObjectData)) {
1596 this->user = UserData{ object };
1597 }
1598 }
1599
1600 GuildScheduledEventUserDataVector::GuildScheduledEventUserDataVector(simdjson::ondemand::value jsonObjectData) {
1601 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
1602 simdjson::ondemand::array arrayValue{};
1603 if (getArray(arrayValue, jsonObjectData)) {
1604 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1605 GuildScheduledEventUserData newData{ value.value() };
1606 this->guildScheduledEventUsers.emplace_back(std::move(newData));
1607 }
1608 }
1609 }
1610 }
1611
1612 GuildScheduledEventDataVector::GuildScheduledEventDataVector(simdjson::ondemand::value jsonObjectData) {
1613 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
1614 simdjson::ondemand::array arrayValue{};
1615 if (getArray(arrayValue, jsonObjectData)) {
1616 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1617 GuildScheduledEventData newData{ value.value() };
1618 this->guildScheduledEvents.emplace_back(std::move(newData));
1619 }
1620 }
1621 }
1622 }
1623
1624 InviteData::InviteData(simdjson::ondemand::value jsonObjectData) {
1625 this->code = getUint32(jsonObjectData, "code");
1626
1627 simdjson::ondemand::value object{};
1628 if (getObject(object, "guild", jsonObjectData)) {
1629 this->guild = GuildData{ object };
1630 }
1631
1632 if (getObject(object, "channel", jsonObjectData)) {
1633 this->channel = ChannelData{ object };
1634 }
1635
1636 if (getObject(object, "inviter", jsonObjectData)) {
1637 this->inviter = UserData{ object };
1638 }
1639
1640 this->targetType = getUint32(jsonObjectData, "target_type");
1641
1642 if (getObject(object, "target_user", jsonObjectData)) {
1643 this->targetUser = UserData{ object };
1644 }
1645
1646 if (getObject(object, "target_application", jsonObjectData)) {
1647 this->targetApplication = ApplicationData{ object };
1648 }
1649
1650 if (getObject(object, "stage_instance", jsonObjectData)) {
1651 this->stageInstance = StageInstanceData{ object };
1652 }
1653
1654 if (getObject(object, "guild_scheduled_event", jsonObjectData)) {
1655 this->guildScheduledEvent = GuildScheduledEventData{ object };
1656 }
1657
1658 this->approximatePresenceCount = getUint32(jsonObjectData, "approximate_presence_count");
1659
1660 this->approximateMemberCount = getUint32(jsonObjectData, "approximate_member_count");
1661
1662 this->guildId = getId(jsonObjectData, "guild_id");
1663
1664 this->expiresAt = getString(jsonObjectData, "expires_at");
1665
1666 this->uses = getUint32(jsonObjectData, "uses");
1667
1668 this->maxUses = getUint32(jsonObjectData, "max_uses");
1669
1670 this->maxAge = getUint32(jsonObjectData, "max_age");
1671
1672 this->temporary = getBool(jsonObjectData, "temporary");
1673
1674 this->createdAt = getString(jsonObjectData, "created_at");
1675 }
1676
1677 InviteDataVector::InviteDataVector(simdjson::ondemand::value jsonObjectData) {
1678 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
1679 simdjson::ondemand::array arrayValue{};
1680 if (getArray(arrayValue, jsonObjectData)) {
1681 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1682 InviteData newData{ value.value() };
1683 this->invites.emplace_back(std::move(newData));
1684 }
1685 }
1686 }
1687 }
1688
1689 GuildTemplateData::GuildTemplateData(simdjson::ondemand::value jsonObjectData) {
1690 simdjson::ondemand::value object{};
1691 if (getObject(object, "serialized_source_guild", jsonObjectData)) {
1692 this->serializedSourceGuild = GuildData{ object };
1693 }
1694
1695 if (getObject(object, "creator", jsonObjectData)) {
1696 this->creator = UserData{ object };
1697 }
1698
1699 this->sourceGuildId = getString(jsonObjectData, "source_guild_id");
1700
1701 this->description = getString(jsonObjectData, "description");
1702
1703 this->usageCount = getUint32(jsonObjectData, "usage_count");
1704
1705 this->creatorId = getString(jsonObjectData, "creator_id");
1706
1707 this->createdAt = getString(jsonObjectData, "created_at");
1708
1709 this->updatedAt = getString(jsonObjectData, "updated_at");
1710
1711 this->isDirty = getBool(jsonObjectData, "is_dirty");
1712
1713 this->code = getString(jsonObjectData, "code");
1714
1715 this->name = getString(jsonObjectData, "name");
1716 }
1717
1718 GuildTemplateDataVector::GuildTemplateDataVector(simdjson::ondemand::value jsonObjectData) {
1719 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
1720 simdjson::ondemand::array arrayValue{};
1721 if (getArray(arrayValue, jsonObjectData)) {
1722 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1723 GuildTemplateData newData{ value.value() };
1724 this->guildTemplates.emplace_back(std::move(newData));
1725 }
1726 }
1727 }
1728 }
1729
1730 WebHookData::WebHookData(simdjson::ondemand::value jsonObjectData) {
1731 this->id = getId(jsonObjectData, "id");
1732
1733 this->type = static_cast<WebHookType>(getUint8(jsonObjectData, "type"));
1734
1735 this->guildId = getId(jsonObjectData, "guild_id");
1736
1737 this->channelId = getId(jsonObjectData, "channel_id");
1738
1739 simdjson::ondemand::value object{};
1740 if (getObject(object, "user", jsonObjectData)) {
1741 this->user = UserData{ object };
1742 }
1743
1744 this->name = getString(jsonObjectData, "name");
1745
1746 this->avatar = getString(jsonObjectData, "avatar");
1747
1748 this->token = getString(jsonObjectData, "token");
1749
1750 this->applicationId = getId(jsonObjectData, "application_id");
1751
1752 if (getObject(object, "source_guild", jsonObjectData)) {
1753 this->sourceGuild = GuildData{ object };
1754 }
1755
1756 if (getObject(object, "source_channel", jsonObjectData)) {
1757 this->sourceChannel = ChannelData{ object };
1758 }
1759
1760 this->url = getString(jsonObjectData, "url");
1761 }
1762
1763 WebHookDataVector::WebHookDataVector(simdjson::ondemand::value jsonObjectData) {
1764 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
1765 simdjson::ondemand::array arrayValue{};
1766 if (getArray(arrayValue, jsonObjectData)) {
1767 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1768 WebHookData newData{ value.value() };
1769 this->webHooks.emplace_back(std::move(newData));
1770 }
1771 }
1772 }
1773 }
1774
1775 AuditLogData::AuditLogData(simdjson::ondemand::value jsonObjectData) {
1776 simdjson::ondemand::array arrayValue{};
1777 if (getArray(arrayValue, "webhooks", jsonObjectData)) {
1778 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1779 WebHookData newData{ value.value() };
1780 this->webhooks.emplace_back(std::move(newData));
1781 }
1782 }
1783
1784 if (getArray(arrayValue, "guild_scheduled_events", jsonObjectData)) {
1785 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1786 GuildScheduledEventData newData{ value.value() };
1787 this->guildScheduledEvents.emplace_back(std::move(newData));
1788 }
1789 }
1790
1791 if (getArray(arrayValue, "auto_moderation_rules", jsonObjectData)) {
1792 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1793 AutoModerationRuleData newData{ value.value() };
1794 this->autoModerationRules.emplace_back(std::move(newData));
1795 }
1796 }
1797
1798 if (getArray(arrayValue, "users", jsonObjectData)) {
1799 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1800 UserData newData{ value.value() };
1801 this->users.emplace_back(std::move(newData));
1802 }
1803 }
1804
1805 if (getArray(arrayValue, "audit_log_entries", jsonObjectData)) {
1806 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1807 AuditLogEntryData newData{ value.value() };
1808 this->auditLogEntries.emplace_back(std::move(newData));
1809 }
1810 }
1811
1812 if (getArray(arrayValue, "integrations", jsonObjectData)) {
1813 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1814 IntegrationData newData{ value.value() };
1815 this->integrations.emplace_back(std::move(newData));
1816 }
1817 }
1818
1819 if (getArray(arrayValue, "threads", jsonObjectData)) {
1820 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1821 ChannelData newData{ value.value() };
1822 this->threads.emplace_back(std::move(newData));
1823 }
1824 }
1825 }
1826
1827 ReactionRemoveData::ReactionRemoveData(simdjson::ondemand::value jsonObjectData) {
1828 this->userId = getId(jsonObjectData, "user_id");
1829
1830 this->channelId = getId(jsonObjectData, "channel_id");
1831
1832 this->messageId = getId(jsonObjectData, "message_id");
1833
1834 this->guildId = getId(jsonObjectData, "guild_id");
1835
1836 simdjson::ondemand::value object{};
1837 if (getObject(object, "emoji", jsonObjectData)) {
1838 this->emoji = EmojiData{ object };
1839 }
1840 }
1841
1842 ApplicationCommandOptionChoiceData::ApplicationCommandOptionChoiceData(simdjson::ondemand::value jsonObjectData) {
1843 std::string_view string{};
1844 uint64_t integer{};
1845 bool theBool{};
1846 double doubleVal{};
1847
1848 if (jsonObjectData["value"].get(string) == simdjson::error_code::SUCCESS) {
1849 this->value = static_cast<std::string>(string);
1850 this->type = JsonType::String;
1851 } else if (jsonObjectData["value"].get(integer) == simdjson::error_code::SUCCESS) {
1852 this->value = std::to_string(integer);
1853 this->type = JsonType::Int64;
1854 } else if (jsonObjectData["value"].get(theBool) == simdjson::error_code::SUCCESS) {
1855 this->type = JsonType::Bool;
1856 std::stringstream stream{};
1857 stream << std::boolalpha << theBool;
1858 this->value = stream.str();
1859 } else if (jsonObjectData["value"].get(doubleVal) == simdjson::error_code::SUCCESS) {
1860 this->type = JsonType::Float;
1861 this->value = std::to_string(doubleVal);
1862 }
1863
1864 this->name = getString(jsonObjectData, "name");
1865
1866 simdjson::ondemand::object map{};
1867 if (jsonObjectData["name_localizations"].get(map) == simdjson::error_code::SUCCESS) {
1868 this->nameLocalizations.clear();
1869 for (auto value: map) {
1870 this->nameLocalizations.emplace(value.unescaped_key().take_value(), value.value().get_string().take_value());
1871 }
1872 }
1873 }
1874
1875 bool operator==(const ApplicationCommandOptionChoiceData& lhs, const ApplicationCommandOptionChoiceData& rhs) {
1876 if (lhs.name != rhs.name) {
1877 return false;
1878 }
1879 if (lhs.nameLocalizations != rhs.nameLocalizations) {
1880 return false;
1881 }
1882 if (lhs.type != rhs.type) {
1883 return false;
1884 }
1885 if (lhs.value != rhs.value) {
1886 return false;
1887 }
1888 return true;
1889 }
1890
1891 ApplicationCommandOptionData::ApplicationCommandOptionData(simdjson::ondemand::value jsonObjectData) {
1892 this->name = getString(jsonObjectData, "name");
1893
1894 simdjson::ondemand::object map{};
1895 if (jsonObjectData["name_localizations"].get(map) == simdjson::error_code::SUCCESS) {
1896 this->nameLocalizations.clear();
1897 for (auto value: map) {
1898 this->nameLocalizations.emplace(value.unescaped_key().take_value(), value.value().get_string().take_value());
1899 }
1900 }
1901
1902 if (jsonObjectData["description_localizations"].get(map) == simdjson::error_code::SUCCESS) {
1903 this->descriptionLocalizations.clear();
1904 for (auto value: map) {
1905 this->descriptionLocalizations.emplace(value.unescaped_key().take_value(), value.value().get_string().take_value());
1906 }
1907 }
1908
1909 this->description = getString(jsonObjectData, "description");
1910
1911 simdjson::ondemand::array arrayValue{};
1912 if (getArray(arrayValue, "channel_types", jsonObjectData)) {
1913 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1914 this->channelTypes.emplace_back(static_cast<ChannelType>(value.get_uint64().value()));
1915 }
1916 }
1917
1918 this->type = static_cast<ApplicationCommandOptionType>(getUint8(jsonObjectData, "type"));
1919
1921 this->minValue = getInt64(jsonObjectData, "min_value");
1922 } else if (this->type == ApplicationCommandOptionType::Number) {
1923 this->minValue = getFloat(jsonObjectData, "min_value");
1924 }
1925
1927 this->maxValue = getInt32(jsonObjectData, "max_value");
1928 } else if (this->type == ApplicationCommandOptionType::Number) {
1929 this->maxValue = getFloat(jsonObjectData, "max_value");
1930 }
1931
1932 this->required = getBool(jsonObjectData, "required");
1933
1934 this->autocomplete = getBool(jsonObjectData, "autocomplete");
1935
1937 if (getArray(arrayValue, "options", jsonObjectData)) {
1938 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1939 ApplicationCommandOptionData newData{ value.value() };
1940 this->options.emplace_back(std::move(newData));
1941 }
1942 }
1943 }
1944 if (getArray(arrayValue, "choices", jsonObjectData)) {
1945 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
1946 ApplicationCommandOptionChoiceData newData{ value.value() };
1947 this->choices.emplace_back(std::move(newData));
1948 }
1949 }
1950 }
1951
1952 bool operator==(const ApplicationCommandOptionData& lhs, const ApplicationCommandOptionData& rhs) {
1953 if (lhs.autocomplete != rhs.autocomplete) {
1954 return false;
1955 }
1956 if (lhs.channelTypes != rhs.channelTypes) {
1957 return false;
1958 }
1959 if (lhs.description != rhs.description) {
1960 return false;
1961 }
1962 if (lhs.descriptionLocalizations != rhs.descriptionLocalizations) {
1963 return false;
1964 }
1965 if (lhs.maxValue != rhs.maxValue) {
1966 return false;
1967 }
1968 if (lhs.minValue != rhs.minValue) {
1969 return false;
1970 }
1971 if (lhs.name != rhs.name) {
1972 return false;
1973 }
1974 if (lhs.nameLocalizations != rhs.nameLocalizations) {
1975 return false;
1976 }
1977 if (lhs.options.size() != rhs.options.size()) {
1978 return false;
1979 }
1980 if (lhs.required != rhs.required) {
1981 return false;
1982 }
1983 if (lhs.type != rhs.type) {
1984 return false;
1985 }
1986 if (lhs.choices.size() != rhs.choices.size()) {
1987 return false;
1988 }
1989 for (int32_t x = 0; x < rhs.choices.size(); ++x) {
1990 if (lhs.choices[x] != rhs.choices[x]) {
1991 }
1992 }
1993 return true;
1994 }
1995
1996 ApplicationCommandData::ApplicationCommandData(simdjson::ondemand::value jsonObjectData) {
1997 this->id = getId(jsonObjectData, "id");
1998
1999 this->defaultMemberPermissions = getString(jsonObjectData, "default_member_permissions");
2000
2001 this->dmPermission = getBool(jsonObjectData, "dm_permission");
2002
2003 this->version = getString(jsonObjectData, "version");
2004
2005 this->type = static_cast<ApplicationCommandType>(getUint8(jsonObjectData, "type"));
2006
2007 simdjson::ondemand::object map{};
2008 if (jsonObjectData["name_localizations"].get(map) == simdjson::error_code::SUCCESS) {
2009 this->nameLocalizations.clear();
2010 for (auto value: map) {
2011 this->nameLocalizations.emplace(value.unescaped_key().take_value(), value.value().get_string().take_value());
2012 }
2013 }
2014
2015 if (jsonObjectData["description_localizations"].get(map) == simdjson::error_code::SUCCESS) {
2016 this->descriptionLocalizations.clear();
2017 for (auto value: map) {
2018 this->descriptionLocalizations.emplace(value.unescaped_key().take_value(), value.value().get_string().take_value());
2019 }
2020 }
2021
2022 this->applicationId = getId(jsonObjectData, "application_id");
2023
2024 this->name = getString(jsonObjectData, "name");
2025
2026 this->description = getString(jsonObjectData, "description");
2027
2028 this->version = getString(jsonObjectData, "version");
2029
2030 simdjson::ondemand::array arrayValue{};
2031 if (getArray(arrayValue, "options", jsonObjectData)) {
2032 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2033 ApplicationCommandOptionData newData{ value.value() };
2034 this->options.emplace_back(std::move(newData));
2035 }
2036 }
2037 }
2038
2039 bool operator==(const ApplicationCommandData& lhs, const ApplicationCommandData& rhs) {
2040 if (lhs.description != rhs.description) {
2041 return false;
2042 }
2043 if (lhs.name != rhs.name) {
2044 return false;
2045 }
2046 if (lhs.type != rhs.type) {
2047 return false;
2048 }
2049 if (lhs.options.size() != rhs.options.size()) {
2050 return false;
2051 }
2052 for (size_t x = 0; x < lhs.options.size(); ++x) {
2053 if (lhs.options[x] != rhs.options[x]) {
2054 return false;
2055 }
2056 }
2057 return true;
2058 }
2059
2060 TypingStartData::TypingStartData(simdjson::ondemand::value jsonObjectData) {
2061 this->channelId = getId(jsonObjectData, "channel_id");
2062
2063 this->guildId = getId(jsonObjectData, "guild_id");
2064
2065 simdjson::ondemand::value object{};
2066 if (getObject(object, "member", jsonObjectData)) {
2067 this->member = GuildMemberData{ object };
2068 }
2069
2070 this->userId = getId(jsonObjectData, "user_id");
2071
2072 this->timeStamp = getUint32(jsonObjectData, "timestamp");
2073 }
2074
2075 YouTubeFormat::YouTubeFormat(simdjson::ondemand::value jsonObjectData) {
2076 this->audioQuality = getString(jsonObjectData, "audioQuality");
2077
2078 this->averageBitrate = getUint32(jsonObjectData, "averageBitrate");
2079
2080 this->audioSampleRate = getString(jsonObjectData, "audioSampleRate");
2081
2082 this->bitrate = getUint32(jsonObjectData, "bitrate");
2083
2084 this->contentLength = strtoull(getString(jsonObjectData, "contentLength"));
2085
2086 this->fps = getUint32(jsonObjectData, "fps");
2087
2088 this->height = getUint32(jsonObjectData, "height");
2089
2090 this->height = getUint32(jsonObjectData, "width");
2091
2092 this->aitags = getString(jsonObjectData, "aitags");
2093
2094 this->itag = getUint32(jsonObjectData, "itag");
2095
2096 this->downloadUrl = getString(jsonObjectData, "url");
2097
2098 this->mimeType = getString(jsonObjectData, "mimeType");
2099
2100 this->quality = getString(jsonObjectData, "quality");
2101
2102 std::string string = getString(jsonObjectData, "signatureCipher");
2103 if (string == "") {
2104 string = getString(jsonObjectData, "cipher");
2105 }
2106
2107 this->signatureCipher = string;
2108
2109 auto ampersandSpFind = this->signatureCipher.find("&sp");
2110 if (ampersandSpFind != std::string::npos) {
2111 this->signature = this->signatureCipher.substr(0, ampersandSpFind);
2112 }
2113
2114 auto urlFind = this->signatureCipher.find("url");
2115 if (urlFind != std::string::npos) {
2116 this->downloadUrl = this->signatureCipher.substr(urlFind + 4);
2117 } else {
2118 this->downloadUrl = getString(jsonObjectData, "url");
2119 }
2120 }
2121
2122 YouTubeFormatVector::YouTubeFormatVector(simdjson::ondemand::value jsonObjectData) {
2123 simdjson::ondemand::value valueNew{};
2124 if (getObject(valueNew, "streamingData", jsonObjectData)) {
2125 simdjson::ondemand::array arrayValue{};
2126 if (getArray(arrayValue, "formats", valueNew)) {
2127 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2128 YouTubeFormat newData{ value.value() };
2129 this->formats.emplace_back(std::move(newData));
2130 }
2131 }
2132 }
2133
2134
2135 if (getObject(valueNew, "streamingData", jsonObjectData)) {
2136 simdjson::ondemand::array arrayValue{};
2137 if (getArray(arrayValue, "adaptiveFormats", valueNew)) {
2138 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2139 YouTubeFormat newData{ value.value() };
2140 this->formats.emplace_back(std::move(newData));
2141 }
2142 }
2143 }
2144 }
2145
2146 UserCommandInteractionData::UserCommandInteractionData(simdjson::ondemand::value jsonObjectData) {
2147 this->targetId = getId(jsonObjectData, "target_id");
2148 }
2149
2150 MessageCommandInteractionData::MessageCommandInteractionData(simdjson::ondemand::value jsonObjectData) {
2151 this->targetId = getId(jsonObjectData, "target_id");
2152 }
2153
2154 ComponentInteractionData::ComponentInteractionData(simdjson::ondemand::value jsonObjectData) {
2155 simdjson::ondemand::array arrayValue{};
2156 if (getArray(arrayValue, "values", jsonObjectData)) {
2157 this->values.clear();
2158 for (auto iterator = arrayValue.begin(); iterator != arrayValue.end(); ++iterator) {
2159 this->values.emplace_back(iterator.value().operator*().get_string().take_value());
2160 }
2161 }
2162
2163 this->customId = getString(jsonObjectData, "custom_id");
2164
2165 this->componentType = static_cast<ComponentType>(getUint8(jsonObjectData, "component_type"));
2166 }
2167
2168 ModalInteractionData::ModalInteractionData(simdjson::ondemand::value jsonObjectData) {
2169 simdjson::ondemand::value theComponent{};
2170 if (jsonObjectData["components"][0]["components"][0].get(theComponent) == simdjson::error_code::SUCCESS) {
2171 this->value = getString(theComponent, "value");
2172 this->customIdSmall = getString(theComponent, "value");
2173 }
2174
2175 this->customId = getString(jsonObjectData, "custom_id");
2176 }
2177
2178 AllowedMentionsData::AllowedMentionsData(simdjson::ondemand::value jsonObjectData) {
2179 simdjson::ondemand::array arrayValue{};
2180 if (getArray(arrayValue, "parse", jsonObjectData)) {
2181 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2182 this->parse.emplace_back(static_cast<std::string>(value.get_string().value()));
2183 }
2184 }
2185
2186 if (getArray(arrayValue, "roles", jsonObjectData)) {
2187 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2188 this->roles.emplace_back(static_cast<std::string>(value.get_string().value()));
2189 }
2190 }
2191
2192 if (getArray(arrayValue, "users", jsonObjectData)) {
2193 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2194 this->users.emplace_back(static_cast<std::string>(value.get_string().value()));
2195 }
2196 }
2197
2198 this->repliedUser = getBool(jsonObjectData, "replied_user");
2199 }
2200
2201 SelectOptionData::SelectOptionData(simdjson::ondemand::value jsonObjectData) {
2202 this->label = getString(jsonObjectData, "label");
2203
2204 this->value = getString(jsonObjectData, "value");
2205
2206 this->description = getString(jsonObjectData, "description");
2207
2208 simdjson::ondemand::value theEmoji{};
2209 if (jsonObjectData["emoji"].get(theEmoji) == simdjson::error_code::SUCCESS) {
2210 this->emoji = EmojiData{ theEmoji };
2211 }
2212
2213 this->_default = getBool(jsonObjectData, "default");
2214 }
2215
2216 ActionRowData::ActionRowData(simdjson::ondemand::value jsonObjectData) {
2217 simdjson::ondemand::array arrayValue{};
2218 if (getArray(arrayValue, "components", jsonObjectData)) {
2219 this->components.clear();
2220 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2221 ComponentData newData{ value.value() };
2222 this->components.emplace_back(std::move(newData));
2223 }
2224 }
2225 }
2226
2227 ComponentData::ComponentData(simdjson::ondemand::value jsonObjectData) {
2228 this->type = static_cast<ComponentType>(getUint8(jsonObjectData, "type"));
2229
2230 this->customId = getString(jsonObjectData, "custom_id");
2231
2232 this->placeholder = getString(jsonObjectData, "placeholder");
2233
2234 this->disabled = getBool(jsonObjectData, "disabled");
2235
2236 this->style = getUint32(jsonObjectData, "style");
2237
2238 this->label = getString(jsonObjectData, "label");
2239
2240 this->minLength = getUint32(jsonObjectData, "min_length");
2241
2242 this->maxLength = getUint32(jsonObjectData, "max_length");
2243
2244 this->maxValues = getUint32(jsonObjectData, "max_values");
2245
2246 this->maxValues = getUint32(jsonObjectData, "min_values");
2247
2248 this->title = getString(jsonObjectData, "title");
2249
2250 this->required = getBool(jsonObjectData, "required");
2251
2252 simdjson::ondemand::value object{};
2253 if (getObject(object, "emoji", jsonObjectData)) {
2254 this->emoji = EmojiData{ object };
2255 }
2256
2257 this->url = getString(jsonObjectData, "url");
2258
2259 simdjson::ondemand::array arrayValue{};
2260 if (getArray(arrayValue, "select_option_data", jsonObjectData)) {
2261 this->options.clear();
2262 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2263 SelectOptionData newData{ value.value() };
2264 this->options.emplace_back(std::move(newData));
2265 }
2266 }
2267
2268 if (getArray(arrayValue, "channel_types", jsonObjectData)) {
2269 this->channelTypes.clear();
2270 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2271 ChannelType newData{ static_cast<ChannelType>(value.value().get_int64().take_value()) };
2272 this->channelTypes.emplace_back(std::move(newData));
2273 }
2274 }
2275 }
2276
2277 ChannelMentionData::ChannelMentionData(simdjson::ondemand::value jsonObjectData) {
2278 this->id = getId(jsonObjectData, "id");
2279
2280 this->guildId = getId(jsonObjectData, "guild_id");
2281
2282 this->type = static_cast<ChannelType>(getUint8(jsonObjectData, "type"));
2283
2284 this->name = getString(jsonObjectData, "name");
2285 }
2286
2287 ChannelPinsUpdateEventData::ChannelPinsUpdateEventData(simdjson::ondemand::value jsonObjectData) {
2288 this->guildId = getId(jsonObjectData, "guild_id");
2289
2290 this->channelId = getId(jsonObjectData, "channel_id");
2291
2292 this->lastPinTimeStamp = getString(jsonObjectData, "last_pin_timestamp");
2293 }
2294
2295 ThreadListSyncData::ThreadListSyncData(simdjson::ondemand::value jsonObjectData) {
2296 this->guildId = getId(jsonObjectData, "guild_id");
2297
2298 simdjson::ondemand::array arrayValue{};
2299 if (getArray(arrayValue, "channel_ids", jsonObjectData)) {
2300 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2301 this->channelIds.emplace_back(value.get_string().take_value());
2302 }
2303 }
2304
2305 if (getArray(arrayValue, "members", jsonObjectData)) {
2306 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2307 ThreadMemberData newData{ value.value() };
2308 this->members.emplace_back(std::move(newData));
2309 }
2310 }
2311
2312 if (getArray(arrayValue, "threads", jsonObjectData)) {
2313 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2314 ChannelData newData{ value.value() };
2315 this->threads.emplace_back(std::move(newData));
2316 }
2317 }
2318 }
2319
2320 ThreadMembersUpdateData::ThreadMembersUpdateData(simdjson::ondemand::value jsonObjectData) {
2321 this->guildId = getId(jsonObjectData, "guild_id");
2322
2323 this->id = getId(jsonObjectData, "id");
2324
2325 this->memberCount = getUint32(jsonObjectData, "member_count");
2326
2327 simdjson::ondemand::array arrayValue{};
2328 if (getArray(arrayValue, "added_members", jsonObjectData)) {
2329 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2330 ThreadMemberData newData{ value.value() };
2331 this->addedMembers.emplace_back(std::move(newData));
2332 }
2333 }
2334
2335 if (getArray(arrayValue, "removed_member_ids", jsonObjectData)) {
2336 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2337 this->removedMemberIds.emplace_back(value.get_string().take_value());
2338 }
2339 }
2340 }
2341
2342 MessageInteractionData::MessageInteractionData(simdjson::ondemand::value jsonObjectData) {
2343 this->id = getId(jsonObjectData, "id");
2344
2345 this->type = static_cast<InteractionType>(getUint8(jsonObjectData, "type"));
2346
2347 this->name = getString(jsonObjectData, "name");
2348
2349 simdjson::ondemand::value object{};
2350 if (getObject(object, "user", jsonObjectData)) {
2351 this->user = UserData{ object };
2352 }
2353
2354 if (getObject(object, "member", jsonObjectData)) {
2355 this->member = GuildMemberData{ object };
2356 }
2357 }
2358
2359 StickerItemData::StickerItemData(simdjson::ondemand::value jsonObjectData) {
2360 this->id = getId(jsonObjectData, "id");
2361
2362 this->name = getString(jsonObjectData, "name");
2363
2364 this->formatType = static_cast<StickerItemType>(getUint8(jsonObjectData, "format_type"));
2365 }
2366
2367 MessageDataOld::MessageDataOld(simdjson::ondemand::value jsonObjectData) {
2368 this->content = getString(jsonObjectData, "content");
2369
2370 this->id = getId(jsonObjectData, "id");
2371
2372 this->channelId = getId(jsonObjectData, "channel_id");
2373
2374 this->guildId = getId(jsonObjectData, "guild_id");
2375
2376 simdjson::ondemand::value object{};
2377 if (getObject(object, "author", jsonObjectData)) {
2378 this->author = UserData{ object };
2379 }
2380
2381 if (getObject(object, "member", jsonObjectData)) {
2382 this->member = GuildMemberData{ object };
2383 }
2384
2385 this->timeStamp = getString(jsonObjectData, "timestamp");
2386
2387 this->editedTimestamp = getString(jsonObjectData, "edited_timestamp");
2388
2389 this->tts = getBool(jsonObjectData, "tts");
2390
2391 this->mentionEveryone = getBool(jsonObjectData, "mention_everyone");
2392
2393
2394 simdjson::ondemand::array arrayValue{};
2395 if (getArray(arrayValue, "mentions", jsonObjectData)) {
2396 this->mentions.clear();
2397 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2398 UserData newData{ value.value() };
2399 this->mentions.emplace_back(std::move(newData));
2400 }
2401 }
2402
2403 if (getArray(arrayValue, "mention_roles", jsonObjectData)) {
2404 this->mentionRoles.clear();
2405 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2406 std::string_view object = value.get_string().take_value();
2407 this->mentionRoles.emplace_back(std::move(object));
2408 }
2409 }
2410
2411 if (getArray(arrayValue, "mention_channels", jsonObjectData)) {
2412 this->mentionChannels.clear();
2413 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2414 ChannelMentionData newChannelData{ value.value() };
2415 this->mentionChannels.emplace_back(std::move(newChannelData));
2416 }
2417 }
2418
2419 if (getArray(arrayValue, "attachments", jsonObjectData)) {
2420 this->attachments.clear();
2421 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2422 AttachmentData newAttachmentData{ value.value() };
2423 this->attachments.emplace_back(std::move(newAttachmentData));
2424 }
2425 }
2426
2427 if (getArray(arrayValue, "embeds", jsonObjectData)) {
2428 this->embeds.clear();
2429 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2430 EmbedData newEmbedData{ value.value() };
2431 this->embeds.emplace_back(std::move(newEmbedData));
2432 }
2433 }
2434
2435 if (getArray(arrayValue, "reactions", jsonObjectData)) {
2436 this->reactions.clear();
2437 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2438 ReactionData newReactionData{ value.value() };
2439 this->reactions.emplace_back(std::move(newReactionData));
2440 }
2441 }
2442
2443 this->nonce = getString(jsonObjectData, "nonce");
2444
2445 this->pinned = getBool(jsonObjectData, "pinned");
2446
2447 this->webHookId = getId(jsonObjectData, "webhook_id");
2448
2449 this->type = static_cast<MessageType>(getUint8(jsonObjectData, "type"));
2450 if (getObject(object, "activity", jsonObjectData)) {
2451 this->activity = MessageActivityData{ object };
2452 }
2453
2454 if (getObject(object, "application", jsonObjectData)) {
2455 this->application = ApplicationData{ object };
2456 }
2457
2458 this->applicationId = getId(jsonObjectData, "application_id");
2459
2460 if (getObject(object, "message_reference", jsonObjectData)) {
2461 this->messageReference = MessageReferenceData{ object };
2462 }
2463
2464 this->flags = getUint32(jsonObjectData, "flags");
2465 if (getArray(arrayValue, "sticker_items", jsonObjectData)) {
2466 this->stickerItems.clear();
2467 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2468 StickerItemData newReactionData{ value.value() };
2469 this->stickerItems.emplace_back(std::move(newReactionData));
2470 }
2471 }
2472
2473 if (getArray(arrayValue, "stickers", jsonObjectData)) {
2474 this->stickers.clear();
2475 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2476 StickerData newReactionData{ value.value() };
2477 this->stickers.emplace_back(std::move(newReactionData));
2478 }
2479 }
2480
2481 if (getObject(object, "interaction", jsonObjectData)) {
2482 this->interaction = MessageInteractionData{ object };
2483 }
2484
2485 if (getArray(arrayValue, "components", jsonObjectData)) {
2486 this->components.clear();
2487 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2488 ActionRowData newActionRowData{ value.value() };
2489 this->components.emplace_back(std::move(newActionRowData));
2490 }
2491 }
2492
2493 if (getObject(object, "thread", jsonObjectData)) {
2494 this->thread = ChannelData{ object };
2495 }
2496 }
2497
2498 MessageData::MessageData(simdjson::ondemand::value jsonObjectData) {
2499 this->content = getString(jsonObjectData, "content");
2500
2501 this->id = getId(jsonObjectData, "id");
2502
2503 this->channelId = getId(jsonObjectData, "channel_id");
2504
2505 this->guildId = getId(jsonObjectData, "guild_id");
2506
2507 simdjson::ondemand::value object{};
2508 if (getObject(object, "author", jsonObjectData)) {
2509 this->author = UserData{ object };
2510 }
2511
2512 if (getObject(object, "member", jsonObjectData)) {
2513 this->member = GuildMemberData{ object };
2514 }
2515
2516 this->timeStamp = getString(jsonObjectData, "timestamp");
2517
2518 this->editedTimestamp = getString(jsonObjectData, "edited_timestamp");
2519
2520 this->tts = getBool(jsonObjectData, "tts");
2521
2522 this->mentionEveryone = getBool(jsonObjectData, "mention_everyone");
2523
2524
2525 simdjson::ondemand::array arrayValue{};
2526 if (getArray(arrayValue, "mentions", jsonObjectData)) {
2527 this->mentions.clear();
2528 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2529 UserData newData{ value.value() };
2530 this->mentions.emplace_back(std::move(newData));
2531 }
2532 }
2533
2534 if (getArray(arrayValue, "mention_roles", jsonObjectData)) {
2535 this->mentionRoles.clear();
2536 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2537 std::string_view object = value.get_string().take_value();
2538 this->mentionRoles.emplace_back(std::move(object));
2539 }
2540 }
2541
2542 if (getArray(arrayValue, "mention_channels", jsonObjectData)) {
2543 this->mentionChannels.clear();
2544 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2545 ChannelMentionData newChannelData{ value.value() };
2546 this->mentionChannels.emplace_back(std::move(newChannelData));
2547 }
2548 }
2549
2550 if (getArray(arrayValue, "attachments", jsonObjectData)) {
2551 this->attachments.clear();
2552 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2553 AttachmentData newAttachmentData{ value.value() };
2554 this->attachments.emplace_back(std::move(newAttachmentData));
2555 }
2556 }
2557
2558 if (getArray(arrayValue, "embeds", jsonObjectData)) {
2559 this->embeds.clear();
2560 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2561 EmbedData newEmbedData{ value.value() };
2562 this->embeds.emplace_back(std::move(newEmbedData));
2563 }
2564 }
2565
2566 if (getArray(arrayValue, "reactions", jsonObjectData)) {
2567 this->reactions.clear();
2568 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2569 ReactionData newReactionData{ value.value() };
2570 this->reactions.emplace_back(std::move(newReactionData));
2571 }
2572 }
2573
2574 this->nonce = getString(jsonObjectData, "nonce");
2575
2576 this->pinned = getBool(jsonObjectData, "pinned");
2577
2578 this->webHookId = getId(jsonObjectData, "webhook_id");
2579
2580 this->type = static_cast<MessageType>(getUint8(jsonObjectData, "type"));
2581
2582 if (getObject(object, "activity", jsonObjectData)) {
2583 this->activity = MessageActivityData{ object };
2584 }
2585
2586 if (getObject(object, "application", jsonObjectData)) {
2587 this->application = ApplicationData{ object };
2588 }
2589
2590 this->applicationId = getId(jsonObjectData, "application_id");
2591
2592 if (getObject(object, "referenced_message", jsonObjectData)) {
2593 this->referencedMessage = std::make_unique<MessageDataOld>(object);
2594 }
2595
2596 if (getObject(object, "message_reference", jsonObjectData)) {
2597 this->messageReference = MessageReferenceData{ object };
2598 }
2599
2600 this->flags = getUint32(jsonObjectData, "flags");
2601
2602 if (getArray(arrayValue, "sticker_items", jsonObjectData)) {
2603 this->stickerItems.clear();
2604 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2605 StickerItemData newReactionData{ value.value() };
2606 this->stickerItems.emplace_back(std::move(newReactionData));
2607 }
2608 }
2609
2610 if (getArray(arrayValue, "stickers", jsonObjectData)) {
2611 this->stickers.clear();
2612 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2613 StickerData newReactionData{ value.value() };
2614 this->stickers.emplace_back(std::move(newReactionData));
2615 }
2616 }
2617
2618 if (getObject(object, "interaction", jsonObjectData)) {
2619 this->interaction = MessageInteractionData{ object };
2620 }
2621
2622 if (getArray(arrayValue, "components", jsonObjectData)) {
2623 this->components.clear();
2624 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2625 ActionRowData newActionRowData{ value.value() };
2626 this->components.emplace_back(std::move(newActionRowData));
2627 }
2628 }
2629
2630 if (getObject(object, "thread", jsonObjectData)) {
2631 this->thread = ChannelData{ object };
2632 }
2633 }
2634
2635 ResolvedData::ResolvedData(simdjson::ondemand::value jsonObjectData) {
2636 simdjson::ondemand::object arrayValue{};
2637 if (jsonObjectData["attachments"].get(arrayValue) == simdjson::error_code::SUCCESS) {
2638 this->attachments.clear();
2639 for (simdjson::simdjson_result<simdjson::ondemand::field> value: arrayValue) {
2640 AttachmentData newData{ value.value() };
2641 this->attachments[strtoull(std::string{ value.key().take_value().raw() })] = std::move(newData);
2642 }
2643 }
2644 if (jsonObjectData["users"].get(arrayValue) == simdjson::error_code::SUCCESS) {
2645 this->users.clear();
2646 for (simdjson::simdjson_result<simdjson::ondemand::field> value: arrayValue) {
2647 UserData newData{ value.value() };
2648 this->users[strtoull(std::string{ value.key().take_value().raw() })] = std::move(newData);
2649 }
2650 }
2651 if (jsonObjectData["channels"].get(arrayValue) == simdjson::error_code::SUCCESS) {
2652 this->channels.clear();
2653 for (simdjson::simdjson_result<simdjson::ondemand::field> value: arrayValue) {
2654 ChannelData newData{ value.value() };
2655 this->channels[strtoull(std::string{ value.key().take_value().raw() })] = std::move(newData);
2656 }
2657 }
2658 if (jsonObjectData["roles"].get(arrayValue) == simdjson::error_code::SUCCESS) {
2659 this->roles.clear();
2660 for (simdjson::simdjson_result<simdjson::ondemand::field> value: arrayValue) {
2661 RoleData newData{ value.value() };
2662 }
2663 }
2664
2665 if (jsonObjectData["members"].get(arrayValue) == simdjson::error_code::SUCCESS) {
2666 this->members.clear();
2667 for (simdjson::simdjson_result<simdjson::ondemand::field> value: arrayValue) {
2668 GuildMemberData newData{ value.value() };
2669 this->members[strtoull(std::string{ value.key().take_value().raw() })] = std::move(newData);
2670 }
2671 }
2672
2673 if (jsonObjectData["messages"].get(arrayValue) == simdjson::error_code::SUCCESS) {
2674 this->messages.clear();
2675 for (simdjson::simdjson_result<simdjson::ondemand::field> value: arrayValue) {
2676 MessageData newData{ value.value() };
2677 this->messages[strtoull(std::string{ value.key().take_value().raw() })] = std::move(newData);
2678 }
2679 }
2680 }
2681
2682 StickerPackData::StickerPackData(simdjson::ondemand::value jsonObjectData) {
2683 simdjson::ondemand::array arrayValue{};
2684 if (getArray(arrayValue, "stickers", jsonObjectData)) {
2685 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2686 StickerData newData{ value.value() };
2687 this->stickers.emplace_back(std::move(newData));
2688 }
2689 }
2690
2691 this->coverStickerId = getString(jsonObjectData, "cover_sticker_id");
2692
2693 this->bannerAssetId = getString(jsonObjectData, "banner_asset_id");
2694
2695 this->description = getString(jsonObjectData, "description");
2696
2697 this->name = getString(jsonObjectData, "name");
2698
2699 this->Id = getId(jsonObjectData, "id");
2700
2701 this->skuId = getString(jsonObjectData, "sku_id");
2702 }
2703
2704 StickerPackDataVector::StickerPackDataVector(simdjson::ondemand::value jsonObjectData) {
2705 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
2706 simdjson::ondemand::array arrayValue{};
2707 if (getArray(arrayValue, jsonObjectData)) {
2708 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2709 StickerPackData newData{ value.value() };
2710 this->stickerPacks.emplace_back(std::move(newData));
2711 }
2712 }
2713 }
2714 }
2715
2716 ConnectionData::ConnectionData(simdjson::ondemand::value jsonObjectData) {
2717 this->name = getString(jsonObjectData, "name");
2718
2719 this->id = getId(jsonObjectData, "id");
2720
2721 this->type = getString(jsonObjectData, "type");
2722
2723 this->showActivity = getBool(jsonObjectData, "show_activity");
2724
2725 this->friendSync = getBool(jsonObjectData, "friend_sync");
2726
2727 this->revoked = getBool(jsonObjectData, "revoked");
2728
2729 this->verified = getBool(jsonObjectData, "verified");
2730
2731 this->visibility = static_cast<ConnectionVisibilityTypes>(getUint8(jsonObjectData, "visibility"));
2732
2733 simdjson::ondemand::array arrayValue{};
2734 if (getArray(arrayValue, "integrations", jsonObjectData)) {
2735 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2736 IntegrationData newData{ value.value() };
2737 this->integrations.emplace_back(std::move(newData));
2738 }
2739 }
2740 }
2741
2742 ApplicationCommandInteractionDataOption::ApplicationCommandInteractionDataOption(simdjson::ondemand::value jsonObjectData) {
2743 this->type = static_cast<ApplicationCommandOptionType>(getUint8(jsonObjectData, "type"));
2744
2745 this->focused = getBool(jsonObjectData, "focused");
2746
2747 this->name = getString(jsonObjectData, "name");
2748
2749 simdjson::ondemand::array arrayValue{};
2750 if (getArray(arrayValue, "options", jsonObjectData)) {
2751 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2752 ApplicationCommandInteractionDataOption newData{ value.value() };
2753 this->options.emplace_back(std::move(newData));
2754 }
2755 }
2756
2757 this->value.type = JsonType::Null;
2758 bool theBool{};
2759 if (jsonObjectData["value"].get(theBool) == simdjson::error_code::SUCCESS) {
2760 this->value.type = JsonType::Bool;
2761 this->value.value = std::to_string(theBool);
2762 return;
2763 }
2764
2765 uint64_t integereger{};
2766 if (jsonObjectData["value"].get(integereger) == simdjson::error_code::SUCCESS) {
2767 this->value.type = JsonType::Uint64;
2768 this->value.value = std::to_string(integereger);
2769 return;
2770 }
2771
2772 std::string_view string{};
2773 if (jsonObjectData["value"].get(string) == simdjson::error_code::SUCCESS) {
2774 this->value.type = JsonType::String;
2775 this->value.value = string;
2776 return;
2777 }
2778
2779 double theFloat{};
2780 if (jsonObjectData["value"].get(theFloat) == simdjson::error_code::SUCCESS) {
2781 this->value.type = JsonType::Float;
2782 this->value.value = std::to_string(theFloat);
2783 return;
2784 }
2785 }
2786
2787 ApplicationCommandInteractionData::ApplicationCommandInteractionData(simdjson::ondemand::value jsonObjectData) {
2788 this->type = static_cast<ApplicationCommandType>(getUint8(jsonObjectData, "type"));
2789
2790 this->name = getString(jsonObjectData, "name");
2791
2792 this->guildId = getId(jsonObjectData, "guild_id");
2793
2794 this->id = getId(jsonObjectData, "id");
2795
2796 simdjson::ondemand::array arrayValue{};
2797 if (getArray(arrayValue, "options", jsonObjectData)) {
2798 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2799 ApplicationCommandInteractionDataOption newData{ value.value() };
2800 this->options.emplace_back(std::move(newData));
2801 }
2802 }
2803
2804 simdjson::ondemand::value object{};
2805 if (getObject(object, "resolved", jsonObjectData)) {
2806 this->resolved = ResolvedData{ object };
2807 }
2808 }
2809
2810 InteractionDataData::InteractionDataData(simdjson::ondemand::value jsonObjectData) {
2811 simdjson::ondemand::value object{};
2812 if (getObject(object, "id", jsonObjectData)) {
2813 this->applicationCommandData = ApplicationCommandInteractionData{ jsonObjectData };
2814 }
2815
2816 if (getObject(object, "target_id", jsonObjectData)) {
2817 this->messageInteractionData = MessageCommandInteractionData{ jsonObjectData };
2818 this->userInteractionData = UserCommandInteractionData{ jsonObjectData };
2819 }
2820
2821 uint64_t componentType{};
2822 if (getObject(object, "component_type", jsonObjectData)) {
2823 this->componentData = ComponentInteractionData{ jsonObjectData };
2824 }
2825
2826 if (getObject(object, "components", jsonObjectData)) {
2827 this->modalData = ModalInteractionData{ jsonObjectData };
2828 }
2829 }
2830
2831 InteractionData::InteractionData(simdjson::ondemand::value jsonObjectData) {
2832 simdjson::ondemand::value object{};
2833 if (getObject(object, "data", jsonObjectData)) {
2834 this->data = InteractionDataData{ object };
2835 }
2836
2837 this->appPermissions = getString(jsonObjectData, "app_permissions");
2838
2839 this->type = static_cast<InteractionType>(getUint8(jsonObjectData, "type"));
2840
2841 this->token = getString(jsonObjectData, "token");
2842 if (getObject(object, "member", jsonObjectData)) {
2843 this->member = GuildMemberData{ object };
2844 this->user.id = this->member.id;
2845 this->user.userName = this->member.getUserData().userName;
2846 }
2847
2848 if (getObject(object, "user", jsonObjectData)) {
2849 this->user = UserData{ object };
2850 }
2851
2852 this->channelId = getId(jsonObjectData, "channel_id");
2853
2854 this->guildId = getId(jsonObjectData, "guild_id");
2855
2856 this->locale = getString(jsonObjectData, "locale");
2857
2858 this->guildLocale = getString(jsonObjectData, "guild_locale");
2859
2860 if (getObject(object, "message", jsonObjectData)) {
2861 this->message = MessageData{ object };
2862 }
2863
2864 this->version = getUint32(jsonObjectData, "version");
2865
2866 this->id = getId(jsonObjectData, "id");
2867
2868 this->applicationId = getId(jsonObjectData, "application_id");
2869 }
2870
2871 SessionStartData::SessionStartData(simdjson::ondemand::value jsonObjectData) {
2872 this->maxConcurrency = getUint32(jsonObjectData, "max_concurrency");
2873
2874 this->remaining = getUint32(jsonObjectData, "remaining");
2875
2876 this->resetAfter = getUint32(jsonObjectData, "reset_after");
2877
2878 this->total = getUint32(jsonObjectData, "total");
2879 }
2880
2881 GatewayBotData::GatewayBotData(simdjson::ondemand::value jsonObjectData) {
2882 this->url = getString(jsonObjectData, "url");
2883
2884 this->shards = getUint32(jsonObjectData, "shards");
2885
2886 simdjson::ondemand::value object{};
2887 if (getObject(object, "session_start_limit", jsonObjectData)) {
2888 this->sessionStartLimit = SessionStartData{ object };
2889 }
2890 }
2891
2892 GuildEmojisUpdateEventData::GuildEmojisUpdateEventData(simdjson::ondemand::value jsonObjectData) {
2893 this->guildId = getId(jsonObjectData, "guild_id");
2894
2895 simdjson::ondemand::array arrayValue{};
2896 if (getArray(arrayValue, "emojis", jsonObjectData)) {
2897 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2898 EmojiData newData{ value.value() };
2899 this->emojis.emplace_back(std::move(newData));
2900 }
2901 }
2902 }
2903
2904 GuildStickersUpdateEventData::GuildStickersUpdateEventData(simdjson::ondemand::value jsonObjectData) {
2905 this->guildId = getId(jsonObjectData, "guild_id");
2906
2907 simdjson::ondemand::array arrayValue{};
2908 if (getArray(arrayValue, "stickers", jsonObjectData)) {
2909 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2910 StickerData newData{ value.value() };
2911 this->stickers.emplace_back(std::move(newData));
2912 }
2913 }
2914 }
2915
2916 GuildMembersChunkEventData::GuildMembersChunkEventData(simdjson::ondemand::value jsonObjectData) {
2917 this->guildId = getId(jsonObjectData, "guild_id");
2918
2919 this->nonce = getString(jsonObjectData, "nonce");
2920
2921 this->chunkIndex = getUint32(jsonObjectData, "chunk_index");
2922
2923 this->chunkCount = getUint32(jsonObjectData, "chunk_count");
2924
2925 simdjson::ondemand::array arrayValue{};
2926 if (getArray(arrayValue, "presences", jsonObjectData)) {
2927 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2928 PresenceUpdateData newData{ value.value() };
2929 this->presences.emplace_back(std::move(newData));
2930 }
2931 }
2932
2933 if (getArray(arrayValue, "not_found", jsonObjectData)) {
2934 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2935 this->notFound.emplace_back(value.get_string().take_value());
2936 }
2937 }
2938
2939 if (getArray(arrayValue, "members", jsonObjectData)) {
2940 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
2941 GuildMemberData newData{ value.value() };
2942 this->members.emplace_back(std::move(newData));
2943 }
2944 }
2945 }
2946
2947 MediaTranscoding::MediaTranscoding(simdjson::ondemand::value jsonObjectData) {
2948 this->thePreset = getString(jsonObjectData, "preset");
2949
2950 this->theUrl = getString(jsonObjectData, "url");
2951 }
2952
2953 Song::Song(simdjson::ondemand::value jsonObjectData) {
2954 this->duration = getString(getObject(getObject(getObject(jsonObjectData, "lengthText"), "accessibility"), "accessibilityData"), "label");
2955 std::string newString = getString(
2956 getObject(getArray(getObject(getObject(getArray(jsonObjectData, "detailedMetadataSnippets"), 0), "snippetText"), "runs"), 0), "text");
2957 if (newString.size() > 256) {
2958 newString = newString.substr(0, 256);
2959 }
2960 this->description = utf8MakeValid(newString);
2961
2962 this->thumbnailUrl = getString(getObject(getArray(getObject(jsonObjectData, "thumbnail"), "thumbnails"), 0), "url");
2963 std::string newTitle01 = getString(getObject(getArray(getObject(jsonObjectData, "title"), "runs"), 0), "text");
2964 if (newTitle01.size() > 256) {
2965 newTitle01 = newTitle01.substr(0, 256);
2966 }
2967 if (newTitle01.size() > 0) {
2968 this->songTitle = utf8MakeValid(newTitle01);
2969 }
2970 std::string newTitle02 = getString(getObject(jsonObjectData, "title"), "simpleText");
2971 if (newTitle02.size() > 256) {
2972 newTitle02 = newTitle02.substr(0, 256);
2973 }
2974 if (newTitle02.size() > 0) {
2975 this->songTitle = utf8MakeValid(newTitle02);
2976 }
2977
2978 if (newTitle01 != "") {
2979 this->songTitle = newTitle01;
2980 } else {
2981 this->songTitle = newTitle02;
2982 }
2983
2984 this->songId = getString(jsonObjectData, "videoId");
2985
2986 this->trackAuthorization = getString(jsonObjectData, "track_authorization");
2987
2988 std::vector<MediaTranscoding> theMedia{};
2989 auto arrayValueNew = getArray(getObject(jsonObjectData, "media"), "transcodings");
2990 if (arrayValueNew.didItSucceed) {
2991 for (auto value: arrayValueNew.arrayValue) {
2992 MediaTranscoding dataNew{ value.value() };
2993 theMedia.emplace_back(dataNew);
2994 }
2995 }
2996
2997 bool isItFound{};
2998 for (auto& value: theMedia) {
2999 if (value.thePreset == "opus_0_0") {
3000 isItFound = true;
3001 this->firstDownloadUrl = value.theUrl;
3002 this->songId = value.theUrl;
3003 this->doWeGetSaved = true;
3004 }
3005 }
3006 bool isItFound2{};
3007 if (!isItFound) {
3008 for (auto& value: theMedia) {
3009 if (value.thePreset == "mp3_0_0") {
3010 this->firstDownloadUrl = value.theUrl;
3011 this->songId = value.theUrl;
3012 isItFound2 = true;
3013 }
3014 }
3015 }
3016 if (!isItFound2 && !isItFound) {
3017 for (auto& value: theMedia) {
3018 this->firstDownloadUrl = value.theUrl;
3019 this->songId = value.theUrl;
3020 }
3021 }
3022
3023 newString = getString(jsonObjectData, "title");
3024 if (newString.size() > 0) {
3025 if (newString.size() > 256) {
3026 newString = newString.substr(0, 256);
3027 }
3028 this->songTitle = utf8MakeValid(newString);
3029 }
3030
3031 newString = getString(jsonObjectData, "description");
3032 if (newString.size() > 0) {
3033 if (newString.size() > 256) {
3034 newString = newString.substr(0, 256);
3035 }
3036 this->description = utf8MakeValid(newString);
3037 this->description += "...";
3038 }
3039
3040 newString = getString(jsonObjectData, "artwork_url");
3041 if (newString.size() > 0) {
3042 this->thumbnailUrl = newString;
3043 }
3044
3045 newString = getString(getObject(jsonObjectData, "user"), "avatar_url");
3046 if (newString.size() > 0) {
3047 this->thumbnailUrl = newString;
3048 }
3049
3050 uint32_t theDuration = getUint32(jsonObjectData, "duration");
3051 if (theDuration != 0) {
3052 this->duration = TimeStamp::convertMsToDurationString(theDuration);
3053 }
3054
3055 newString = getString(jsonObjectData, "permalink_url");
3056 if (newString.size() > 0) {
3057 this->viewUrl = newString;
3058 }
3059 }
3060
3061 AttachmentData::operator Jsonifier() {
3062 Jsonifier data{};
3063 data["content_type"] = this->contentType;
3064 data["description"] = this->description;
3065 data["ephemeral"] = this->ephemeral;
3066 data["file_name"] = this->filename;
3067 data["proxy_url"] = this->proxyUrl;
3068 data["height"] = this->height;
3069 data["width"] = this->width;
3070 data["size"] = this->size;
3071 data["url"] = this->url;
3072 return data;
3073 }
3074
3075 EmbedFieldData::operator Jsonifier() {
3076 Jsonifier data{};
3077 data["inline"] = this->Inline;
3078 data["value"] = escapeCharacters(this->value);
3079 data["name"] = escapeCharacters(this->name);
3080 return data;
3081 }
3082
3083 EmbedData::operator Jsonifier() {
3084 Jsonifier data{};
3085 for (auto& value2: this->fields) {
3086 data["fields"].emplaceBack(value2.operator Jsonifier());
3087 }
3088 std::string realColorVal = std::to_string(this->hexColorValue.getIntColorValue());
3089 data["footer"]["proxy_icon_url"] = this->footer.proxyIconUrl;
3090 data["footer"]["icon_url"] = this->footer.iconUrl;
3091 data["footer"]["text"] = escapeCharacters(this->footer.text);
3092 data["author"]["proxy_icon_url"] = this->author.proxyIconUrl;
3093 data["author"]["icon_url"] = this->author.iconUrl;
3094 data["author"]["name"] = this->author.name;
3095 data["author"]["url"] = this->author.url;
3096 data["thumbnail"]["proxy_url"] = this->thumbnail.proxyUrl;
3097 data["thumbnail"]["height"] = this->thumbnail.height;
3098 data["thumbnail"]["width"] = this->thumbnail.width;
3099 data["thumbnail"]["url"] = this->thumbnail.url;
3100 data["image"]["proxy_url"] = this->image.proxyUrl;
3101 data["image"]["height"] = this->image.height;
3102 data["image"]["width"] = this->image.width;
3103 data["image"]["url"] = this->image.url;
3104 data["video"]["proxy_url"] = this->video.proxyUrl;
3105 data["video"]["height"] = this->video.height;
3106 data["video"]["url"] = this->video.url;
3107 data["video"]["width"] = this->video.width;
3108 data["provider"]["name"] = this->provider.name;
3109 data["provider"]["url"] = this->provider.url;
3110 data["description"] = escapeCharacters(this->description);
3111 data["timestamp"] = this->timeStamp;
3112 data["title"] = escapeCharacters(this->title);
3113 data["color"] = realColorVal;
3114 data["type"] = this->type;
3115 data["url"] = this->url;
3116 return data;
3117 }
3118
3119 EmbedData& EmbedData::setAuthor(const std::string& authorName, const std::string& authorAvatarUrl) {
3120 this->author.name = authorName;
3121 this->author.iconUrl = authorAvatarUrl;
3122 return *this;
3123 }
3124
3125 EmbedData& EmbedData::setFooter(const std::string& footerText, const std::string& footerIconUrlText) {
3126 this->footer.text = footerText;
3127 this->footer.iconUrl = footerIconUrlText;
3128 return *this;
3129 }
3130
3131 EmbedData& EmbedData::setTimeStamp(const std::string& timeStamp) {
3132 this->timeStamp = timeStamp;
3133 return *this;
3134 }
3135
3136 EmbedData& EmbedData::addField(const std::string& name, const std::string& value, bool Inline) {
3137 EmbedFieldData field{};
3138 field.Inline = Inline;
3139 field.value = value;
3140 field.name = name;
3141 this->fields.emplace_back(field);
3142 return *this;
3143 }
3144
3145 EmbedData& EmbedData::setDescription(const std::string& descriptionNew) {
3146 this->description = descriptionNew;
3147 return *this;
3148 }
3149
3150 EmbedData& EmbedData::setColor(const std::string& hexColorValueNew) {
3151 this->hexColorValue = hexColorValueNew;
3152 return *this;
3153 }
3154
3155 EmbedData& EmbedData::setThumbnail(const std::string& thumbnailUrl) {
3156 this->thumbnail.url = thumbnailUrl;
3157 return *this;
3158 }
3159
3160 EmbedData& EmbedData::setTitle(const std::string& titleNew) {
3161 this->title = titleNew;
3162 return *this;
3163 }
3164
3165 EmbedData& EmbedData::setImage(const std::string& imageUrl) {
3166 this->image.url = imageUrl;
3167 return *this;
3168 }
3169
3170 MessageReferenceData::operator Jsonifier() {
3171 Jsonifier data{};
3172 data["fail_if_not_exists"] = this->failIfNotExists;
3173 data["message_id"] = this->messageId;
3174 data["channel_id"] = this->channelId;
3175 data["guild_id"] = this->guildId;
3176 return data;
3177 }
3178
3179 GuildApplicationCommandPermissionsDataVector::operator std::vector<GuildApplicationCommandPermissionsData>() {
3180 return this->guildApplicationCommandPermissionss;
3181 }
3182
3183 BanDataVector::operator std::vector<BanData>() {
3184 return this->bans;
3185 }
3186
3187 UpdateVoiceStateData::operator Jsonifier() {
3188 Jsonifier data{};
3189 data["op"] = 4;
3190 if (this->channelId == 0) {
3191 data["d"]["channel_id"] = JsonType::Null;
3192 } else {
3193 data["d"]["channel_id"] = this->channelId;
3194 }
3195 data["d"]["self_deaf"] = this->selfDeaf;
3196 data["d"]["self_mute"] = this->selfMute;
3197 data["d"]["guild_id"] = this->guildId;
3198 return data;
3199 }
3200
3201 GuildDataVector::operator std::vector<GuildData>() {
3202 return this->guilds;
3203 }
3204
3205 GuildScheduledEventUserDataVector::operator std::vector<GuildScheduledEventUserData>() {
3206 return this->guildScheduledEventUsers;
3207 }
3208
3209 GuildScheduledEventDataVector::operator std::vector<GuildScheduledEventData>() {
3210 return this->guildScheduledEvents;
3211 }
3212
3213 InviteDataVector::operator std::vector<InviteData>() {
3214 return this->invites;
3215 }
3216
3217 GuildTemplateDataVector::operator std::vector<GuildTemplateData>() {
3218 return this->guildTemplates;
3219 }
3220
3221 WebHookDataVector::operator std::vector<WebHookData>() {
3222 return this->webHooks;
3223 }
3224
3225 auto AuditLogData::getAuditLogData(const Snowflake userIdOfChanger, AuditLogEvent auditLogType) {
3226 for (auto& value: this->auditLogEntries) {
3227 if (value.id == userIdOfChanger && value.actionType == auditLogType) {
3228 return value;
3229 }
3230 }
3231 return AuditLogEntryData();
3232 }
3233
3234 auto AuditLogData::getAuditLogData(AuditLogEvent auditLogType, const Snowflake userIdOfTarget) {
3235 for (auto& value: this->auditLogEntries) {
3236 if (value.targetId == userIdOfTarget && value.actionType == auditLogType) {
3237 return value;
3238 }
3239 }
3240 return AuditLogEntryData();
3241 }
3242
3243 ApplicationCommandOptionChoiceData::operator Jsonifier() {
3244 Jsonifier data{};
3245 data["name"] = this->name;
3246 data["name_localizations"] = this->nameLocalizations;
3247 switch (this->type) {
3248 case JsonType::Int64: {
3249 data["value"] = uint64_t{ stoull(this->value) };
3250 break;
3251 }
3252 case JsonType::Uint64: {
3253 data["value"] = uint64_t{ stoull(this->value) };
3254 break;
3255 }
3256 case JsonType::Float: {
3257 data["value"] = double{ stod(this->value) };
3258 break;
3259 }
3260 case JsonType::Bool: {
3261 if (this->value == "false") {
3262 data["value"] = bool{};
3263 } else {
3264 data["value"] = bool{ true };
3265 }
3266 break;
3267 }
3268 case JsonType::String: {
3269 data["value"] = this->value;
3270 break;
3271 }
3272 case JsonType::Null: {
3273 data["value"] = this->value;
3274 break;
3275 }
3276 }
3277 return data;
3278 }
3279
3280 ApplicationCommandOptionData::operator Jsonifier() {
3281 Jsonifier data{};
3282 if (this->type == ApplicationCommandOptionType::Channel) {
3283 data["channel_types"] = this->channelTypes;
3284 }
3286 data["required"] = this->required;
3287 }
3288 if (this->descriptionLocalizations.size() > 0) {
3289 data["description_localizations"] = this->descriptionLocalizations;
3290 }
3291 if (this->nameLocalizations.size() > 0) {
3292 data["name_localizations"] = this->nameLocalizations;
3293 }
3294 data["description"] = this->description;
3295 if (this->minValue != std::numeric_limits<int32_t>::max()) {
3296 data["min_value"] = this->minValue;
3297 }
3298 if (this->maxValue != std::numeric_limits<int32_t>::min()) {
3299 data["max_value"] = this->maxValue;
3300 }
3301 data["required"] = this->required;
3302 data["name"] = this->name;
3303 data["type"] = this->type;
3304 for (auto& value: this->choices) {
3305 data["choices"].emplaceBack(value.operator Jsonifier());
3306 }
3307 if (this->choices.size() == 0) {
3308 data["autocomplete"] = this->autocomplete;
3309 }
3310 for (auto& value: this->options) {
3311 data["options"].emplaceBack(value.operator Jsonifier());
3312 }
3313 return data;
3314 }
3315
3316 ThreadMemberDataVector::operator std::vector<ThreadMemberData>() {
3317 return this->threadMembers;
3318 }
3319
3320 YouTubeFormatVector::operator std::vector<YouTubeFormat>() {
3321 return this->formats;
3322 }
3323
3324 AudioFrameData& AudioFrameData::operator+=(std::basic_string_view<std::byte> other) noexcept {
3325 if (this->data.size() < this->currentSize + other.size()) {
3326 this->data.resize(other.size() + this->currentSize);
3327 }
3328 std::copy(other.data(), other.data() + other.size(), this->data.data() + this->currentSize);
3329 this->currentSize += other.size();
3330 this->type = AudioFrameType::RawPCM;
3331 return *this;
3332 }
3333
3334 AudioFrameData& AudioFrameData::operator+=(std::byte character) {
3335 this->currentSize++;
3336 this->data.push_back(character);
3337 return *this;
3338 }
3339
3340 bool operator==(const AudioFrameData& lhs, const AudioFrameData& rhs) {
3341 if (lhs.data != rhs.data) {
3342 return false;
3343 }
3344 if (lhs.currentSize != rhs.currentSize) {
3345 return false;
3346 }
3347 if (lhs.guildMemberId != rhs.guildMemberId) {
3348 return false;
3349 }
3350 if (lhs.type != rhs.type) {
3351 return false;
3352 }
3353 return true;
3354 }
3355
3356 AudioFrameData& AudioFrameData::operator=(AudioFrameData&& other) noexcept {
3357 if (this->data.size() < other.data.size() + this->currentSize) {
3358 this->data.resize(other.data.size() + this->currentSize);
3359 }
3360 std::copy(other.data.data(), other.data.data() + other.data.size(), this->data.data() + this->currentSize);
3361 this->currentSize += other.data.size();
3362 this->guildMemberId = std::move(other.guildMemberId);
3363 this->type = other.type;
3364 other.currentSize = 0;
3365 other.type = AudioFrameType::Unset;
3366 return *this;
3367 }
3368
3369 AudioFrameData::AudioFrameData(AudioFrameData&& other) noexcept {
3370 *this = std::move(other);
3371 }
3372
3373 void AudioFrameData::clearData() noexcept {
3375 this->guildMemberId = 0;
3376 this->currentSize = 0;
3377 this->data.clear();
3378 }
3379
3380 AllowedMentionsData::operator Jsonifier() {
3381 Jsonifier data{};
3382 for (auto& value: this->parse) {
3383 data["parse"].emplaceBack(value);
3384 }
3385 for (auto& value: this->roles) {
3386 data["roles"].emplaceBack(value);
3387 }
3388 for (auto& value: this->users) {
3389 data["users"].emplaceBack(value);
3390 }
3391 data["replied_user"] = this->repliedUser;
3392 return data;
3393 }
3394
3395 ActionRowData::operator Jsonifier() {
3396 Jsonifier data{};
3397 data["type"] = 1;
3398 if (this->components.size() > 0) {
3399 for (auto& valueNew: this->components) {
3400 if (valueNew.type == ComponentType::Button) {
3401 Jsonifier component{};
3402 if (valueNew.emoji.name != "") {
3403 component["emoji"]["animated"] = valueNew.emoji.animated;
3404 component["emoji"]["name"] = std::string{ valueNew.emoji.name };
3405 if (valueNew.emoji.id != 0) {
3406 component["emoji"]["id"] = valueNew.emoji.id;
3407 }
3408 }
3409 component["custom_id"] = valueNew.customId;
3410 component["disabled"] = valueNew.disabled;
3411 component["label"] = valueNew.label;
3412 component["style"] = valueNew.style;
3413 component["type"] = valueNew.type;
3414 component["url"] = valueNew.url;
3415 data["components"].emplaceBack(component);
3416 } else if (valueNew.type == ComponentType::String_Select || valueNew.type == ComponentType::User_Select ||
3417 valueNew.type == ComponentType::Role_Select || valueNew.type == ComponentType::Mentionable_Select ||
3418 valueNew.type == ComponentType::Channel_Select) {
3419 Jsonifier component{};
3420 for (auto& value01: valueNew.options) {
3421 Jsonifier option{};
3422 if (valueNew.emoji.name != "") {
3423 component["emoji"]["animated"] = valueNew.emoji.animated;
3424 component["emoji"]["name"] = std::string{ valueNew.emoji.name };
3425 if (valueNew.emoji.id != 0) {
3426 component["emoji"]["id"] = valueNew.emoji.id;
3427 }
3428 }
3429 option["description"] = value01.description;
3430 option["default"] = value01._default;
3431 option["label"] = value01.label;
3432 option["value"] = value01.value;
3433 component["options"].emplaceBack(option);
3434 };
3435 component["placeholder"] = valueNew.placeholder;
3436 component["max_values"] = valueNew.maxValues;
3437 component["min_values"] = valueNew.minValues;
3438 component["custom_id"] = valueNew.customId;
3439 component["disabled"] = valueNew.disabled;
3440 component["type"] = valueNew.type;
3441 data["components"].emplaceBack(component);
3442
3443 } else if (valueNew.type == ComponentType::Text_Input) {
3444 Jsonifier component{};
3445 component["placeholder"] = valueNew.placeholder;
3446 component["min_length"] = valueNew.minLength;
3447 component["max_length"] = valueNew.maxLength;
3448 component["custom_id"] = valueNew.customId;
3449 component["required"] = valueNew.required;
3450 component["style"] = valueNew.style;
3451 component["label"] = valueNew.label;
3452 component["value"] = valueNew.value;
3453 component["type"] = valueNew.type;
3454 data["components"].emplaceBack(component);
3455 }
3456 }
3457 }
3458 return data;
3459 }
3460
3461 MessageData& MessageData::operator=(const MessageData& other) {
3462 if (this != &other) {
3463 if (other.referencedMessage) {
3464 *this->referencedMessage = *other.referencedMessage;
3465 }
3466 this->messageReference = other.messageReference;
3467 this->mentionEveryone = other.mentionEveryone;
3468 this->mentionChannels = other.mentionChannels;
3469 this->editedTimestamp = other.editedTimestamp;
3470 this->applicationId = other.applicationId;
3471 this->stickerItems = other.stickerItems;
3472 this->mentionRoles = other.mentionRoles;
3473 this->application = other.application;
3474 this->interaction = other.interaction;
3475 this->attachments = other.attachments;
3476 this->components = other.components;
3477 this->timeStamp = other.timeStamp;
3478 this->channelId = other.channelId;
3479 this->webHookId = other.webHookId;
3480 this->reactions = other.reactions;
3481 this->activity = other.activity;
3482 this->mentions = other.mentions;
3483 this->stickers = other.stickers;
3484 this->content = other.content;
3485 this->guildId = other.guildId;
3486 this->member = other.member;
3487 this->thread = other.thread;
3488 this->pinned = other.pinned;
3489 this->author = other.author;
3490 this->embeds = other.embeds;
3491 this->nonce = other.nonce;
3492 this->flags = other.flags;
3493 this->type = other.type;
3494 this->tts = other.tts;
3495 this->id = other.id;
3496 }
3497 return *this;
3498 }
3499
3500 MessageData::MessageData(const MessageData& other) {
3501 *this = other;
3502 }
3503
3504 StickerPackDataVector::operator std::vector<StickerPackData>() {
3505 return this->stickerPacks;
3506 }
3507
3508 ConnectionDataVector::operator std::vector<ConnectionData>() {
3509 return this->connections;
3510 }
3511
3512 ConnectionDataVector::ConnectionDataVector(simdjson::ondemand::value jsonObjectData) noexcept {
3513 if (jsonObjectData.type() != simdjson::ondemand::json_type::null) {
3514 simdjson::ondemand::array arrayValue{};
3515 if (getArray(arrayValue, jsonObjectData)) {
3516 for (simdjson::simdjson_result<simdjson::ondemand::value> value: arrayValue) {
3517 ConnectionData newData{ value.value() };
3518 this->connections.emplace_back(std::move(newData));
3519 }
3520 }
3521 }
3522 }
3523
3524 VoiceRegionDataVector::operator std::vector<VoiceRegionData>() {
3525 return this->voiceRegions;
3526 }
3527
3528 IntegrationDataVector::operator std::vector<IntegrationData>() {
3529 return this->integeregrations;
3530 }
3531
3532 InputEventData& InputEventData::operator=(InputEventData&& other) noexcept {
3533 if (this != &other) {
3534 *this->interactionData = std::move(*other.interactionData);
3535 this->responseType = other.responseType;
3536 }
3537 return *this;
3538 }
3539
3540 InputEventData::InputEventData(InputEventData&& other) noexcept {
3541 *this = std::move(other);
3542 }
3543
3544 InputEventData& InputEventData::operator=(const InputEventData& other) noexcept {
3545 if (this != &other) {
3546 *this->interactionData = *other.interactionData;
3547 this->responseType = other.responseType;
3548 }
3549 return *this;
3550 }
3551
3552 InputEventData::InputEventData(const InputEventData& other) noexcept {
3553 *this = other;
3554 }
3555
3556 InputEventData& InputEventData::operator=(const InteractionData& other) noexcept {
3557 *this->interactionData = other;
3558 return *this;
3559 }
3560
3561 InputEventData::InputEventData(const InteractionData& interactionData) noexcept {
3562 *this = interactionData;
3563 }
3564
3566 UserData returnData{};
3567 returnData.id = this->interactionData->user.id;
3568 returnData = Users::getCachedUser({ .userId = returnData.id });
3569 return this->interactionData->user;
3570 }
3571
3573 ChannelData returnData{};
3574 returnData.id = this->interactionData->channelId;
3575 returnData = Channels::getCachedChannel({ returnData.id });
3576 return returnData;
3577 }
3578
3580 GuildMemberData returnData{ this->interactionData->member };
3581 returnData = GuildMembers::getCachedGuildMember({ .guildMemberId = returnData.id, .guildId = this->interactionData->guildId });
3582 return returnData;
3583 }
3584
3586 GuildData returnData{};
3587 returnData.id = this->interactionData->guildId;
3588 returnData = Guilds::getCachedGuild({ .guildId = this->interactionData->guildId });
3589 return returnData;
3590 }
3591
3593 return *this->interactionData;
3594 }
3595
3597 return this->interactionData->message;
3598 }
3599
3600 RespondToInputEventData& RespondToInputEventData::operator=(const InteractionData& dataPackage) {
3601 this->applicationId = dataPackage.applicationId;
3602 this->interactionToken = dataPackage.token;
3603 this->messageId = dataPackage.message.id;
3604 this->channelId = dataPackage.channelId;
3605 this->interactionId = dataPackage.id;
3606 this->eventType = dataPackage.type;
3607 return *this;
3608 };
3609
3610 RespondToInputEventData::RespondToInputEventData(const InteractionData& dataPackage) {
3611 *this = dataPackage;
3612 }
3613
3614 RespondToInputEventData& RespondToInputEventData::operator=(const InputEventData& dataPackage) {
3615 this->applicationId = dataPackage.getInteractionData().applicationId;
3616 this->interactionToken = dataPackage.getInteractionData().token;
3617 this->interactionId = dataPackage.getInteractionData().id;
3618 this->channelId = dataPackage.getChannelData().id;
3619 this->messageId = dataPackage.getMessageData().id;
3620 return *this;
3621 }
3622
3623 RespondToInputEventData::RespondToInputEventData(const InputEventData& dataPackage) {
3624 *this = dataPackage;
3625 }
3626
3627 RespondToInputEventData& RespondToInputEventData::addButton(bool disabled, const std::string& customIdNew, const std::string& buttonLabel,
3628 ButtonStyle buttonStyle, const std::string& emojiName, Snowflake emojiId, const std::string& url) {
3629 if (this->components.size() == 0) {
3630 ActionRowData actionRowData;
3631 this->components.emplace_back(actionRowData);
3632 }
3633 if (this->components.size() < 5) {
3634 if (this->components[this->components.size() - 1].components.size() < 5) {
3635 ComponentData component;
3636 component.type = ComponentType::Button;
3637 component.emoji.name = emojiName;
3638 component.label = buttonLabel;
3639 component.style = static_cast<int32_t>(buttonStyle);
3640 component.customId = customIdNew;
3641 component.disabled = disabled;
3642 component.emoji.id = emojiId;
3643 component.url = url;
3644 this->components[this->components.size() - 1].components.emplace_back(component);
3645 } else if (this->components[this->components.size() - 1].components.size() == 5) {
3646 ActionRowData actionRowData;
3647 this->components.emplace_back(actionRowData);
3648 }
3649 }
3650 return *this;
3651 }
3652
3653 RespondToInputEventData& RespondToInputEventData::addSelectMenu(bool disabled, const std::string& customIdNew,
3654 std::vector<SelectOptionData> options, const std::string& placeholder, int32_t maxValues, int32_t minValues, SelectMenuType type,
3655 std::vector<ChannelType> channelTypes) {
3656 if (this->components.size() == 0) {
3657 ActionRowData actionRowData;
3658 this->components.emplace_back(actionRowData);
3659 }
3660 if (this->components.size() < 5) {
3661 if (this->components[this->components.size() - 1].components.size() < 5) {
3662 ComponentData componentData;
3663 componentData.type = static_cast<ComponentType>(type);
3664 componentData.channelTypes = channelTypes;
3665 componentData.placeholder = placeholder;
3666 componentData.customId = customIdNew;
3667 componentData.maxValues = maxValues;
3668 componentData.minValues = minValues;
3669 componentData.disabled = disabled;
3670 componentData.options = options;
3671 this->components[this->components.size() - 1].components.emplace_back(componentData);
3672 } else if (this->components[this->components.size() - 1].components.size() == 5) {
3673 ActionRowData actionRowData;
3674 this->components.emplace_back(actionRowData);
3675 }
3676 }
3677 return *this;
3678 }
3679
3680 RespondToInputEventData& RespondToInputEventData::addModal(const std::string& topTitleNew, const std::string& topCustomIdNew,
3681 const std::string& titleNew, const std::string& customIdNew, bool required, int32_t minLength, int32_t maxLength, TextInputStyle inputStyle,
3682 const std::string& label, const std::string& placeholder) {
3683 this->title = topTitleNew;
3684 this->customId = topCustomIdNew;
3685 if (this->components.size() == 0) {
3686 ActionRowData actionRowData;
3687 this->components.emplace_back(actionRowData);
3688 }
3689 if (this->components.size() < 5) {
3690 if (this->components[this->components.size() - 1].components.size() < 5) {
3691 ComponentData component{};
3692 component.type = ComponentType::Text_Input;
3693 component.customId = customIdNew;
3694 component.style = static_cast<int32_t>(inputStyle);
3695 component.title = titleNew;
3696 component.maxLength = maxLength;
3697 component.minLength = minLength;
3698 component.label = label;
3699 component.required = required;
3700 component.placeholder = placeholder;
3701 this->components[this->components.size() - 1].components.emplace_back(component);
3702 } else if (this->components[this->components.size() - 1].components.size() == 5) {
3703 ActionRowData actionRowData;
3704 this->components.emplace_back(actionRowData);
3705 }
3706 }
3707 return *this;
3708 }
3709
3711 this->files.emplace_back(theFile);
3712 return *this;
3713 }
3714
3716 this->allowedMentions = dataPackage;
3717 return *this;
3718 }
3719
3721 this->type = typeNew;
3722 return *this;
3723 }
3724
3726 this->components.emplace_back(dataPackage);
3727 return *this;
3728 }
3729
3731 this->embeds.emplace_back(dataPackage);
3732 return *this;
3733 }
3734
3736 this->content = dataPackage;
3737 return *this;
3738 }
3739
3741 this->tts = enabledTTs;
3742 return *this;
3743 }
3744
3746 std::unordered_map<std::string, std::string> theNameLocalizations) {
3748 choiceData.nameLocalizations = theNameLocalizations;
3749 choiceData.name = theName;
3750 switch (value.getType()) {
3751 case JsonType::String: {
3752 choiceData.type = JsonType::String;
3753 break;
3754 }
3755 case JsonType::Float: {
3756 choiceData.type = JsonType::Float;
3757 break;
3758 }
3759 case JsonType::Uint64: {
3760 choiceData.type = JsonType::Uint64;
3761 break;
3762 }
3763 case JsonType::Int64: {
3764 choiceData.type = JsonType::Int64;
3765 break;
3766 }
3767 case JsonType::Bool: {
3768 choiceData.type = JsonType::Bool;
3769 break;
3770 }
3771 }
3772 value.refreshString(JsonifierSerializeType::Json);
3773 choiceData.value = value.operator std::string();
3774 this->choices.emplace_back(choiceData);
3775 return *this;
3776 }
3777
3779 this->targetUserId = targetUserIdNew;
3780 return *this;
3781 }
3782
3783 MessageResponseBase& MessageResponseBase::addButton(bool disabled, const std::string& customIdNew, const std::string& buttonLabel,
3784 ButtonStyle buttonStyle, const std::string& emojiName, Snowflake emojiId, const std::string& url) {
3785 if (this->components.size() == 0) {
3786 ActionRowData actionRowData;
3787 this->components.emplace_back(actionRowData);
3788 }
3789 if (this->components.size() < 5) {
3790 if (this->components[this->components.size() - 1].components.size() < 5) {
3791 ComponentData component;
3792 component.type = ComponentType::Button;
3793 component.emoji.name = emojiName;
3794 component.label = buttonLabel;
3795 component.style = static_cast<int32_t>(buttonStyle);
3796 component.customId = customIdNew;
3797 component.disabled = disabled;
3798 component.emoji.id = emojiId;
3799 component.url = url;
3800 this->components[this->components.size() - 1].components.emplace_back(component);
3801 } else if (this->components[this->components.size() - 1].components.size() == 5) {
3802 ActionRowData actionRowData;
3803 this->components.emplace_back(actionRowData);
3804 }
3805 }
3806 return *this;
3807 }
3808
3809 MessageResponseBase& MessageResponseBase::addSelectMenu(bool disabled, const std::string& customIdNew, std::vector<SelectOptionData> options,
3810 const std::string& placeholder, int32_t maxValues, int32_t minValues, SelectMenuType type, std::vector<ChannelType> channelTypes) {
3811 if (this->components.size() == 0) {
3812 ActionRowData actionRowData;
3813 this->components.emplace_back(actionRowData);
3814 }
3815 if (this->components.size() < 5) {
3816 if (this->components[this->components.size() - 1].components.size() < 5) {
3817 ComponentData componentData;
3818 componentData.type = static_cast<ComponentType>(type);
3819 componentData.channelTypes = channelTypes;
3820 componentData.placeholder = placeholder;
3821 componentData.customId = customIdNew;
3822 componentData.maxValues = maxValues;
3823 componentData.minValues = minValues;
3824 componentData.disabled = disabled;
3825 componentData.options = options;
3826 this->components[this->components.size() - 1].components.emplace_back(componentData);
3827 } else if (this->components[this->components.size() - 1].components.size() == 5) {
3828 ActionRowData actionRowData;
3829 this->components.emplace_back(actionRowData);
3830 }
3831 }
3832 return *this;
3833 }
3834
3835 MessageResponseBase& MessageResponseBase::addModal(const std::string& topTitleNew, const std::string& topCustomIdNew, const std::string& titleNew,
3836 const std::string& customIdNew, bool required, int32_t minLength, int32_t maxLength, TextInputStyle inputStyle, const std::string& label,
3837 const std::string& placeholder) {
3838 this->title = topTitleNew;
3839 this->customId = topCustomIdNew;
3840 if (this->components.size() == 0) {
3841 ActionRowData actionRowData;
3842 this->components.emplace_back(actionRowData);
3843 }
3844 if (this->components.size() < 5) {
3845 if (this->components[this->components.size() - 1].components.size() < 5) {
3846 ComponentData component{};
3847 component.type = ComponentType::Text_Input;
3848 component.customId = customIdNew;
3849 component.style = static_cast<int32_t>(inputStyle);
3850 component.title = titleNew;
3851 component.maxLength = maxLength;
3852 component.minLength = minLength;
3853 component.label = label;
3854 component.required = required;
3855 component.placeholder = placeholder;
3856 this->components[this->components.size() - 1].components.emplace_back(component);
3857 } else if (this->components[this->components.size() - 1].components.size() == 5) {
3858 ActionRowData actionRowData;
3859 this->components.emplace_back(actionRowData);
3860 }
3861 }
3862 return *this;
3863 }
3864
3866 this->files.emplace_back(theFile);
3867 return *this;
3868 }
3869
3871 this->allowedMentions = dataPackage;
3872 return *this;
3873 }
3874
3876 this->components.emplace_back(dataPackage);
3877 return *this;
3878 }
3879
3881 this->embeds.emplace_back(dataPackage);
3882 return *this;
3883 }
3884
3885 MessageResponseBase& MessageResponseBase::addContent(const std::string& dataPackage) {
3886 this->content = dataPackage;
3887 return *this;
3888 }
3889
3891 this->tts = enabledTTs;
3892 return *this;
3893 }
3894
3895 InteractionResponseData& InteractionResponseData::operator=(const RespondToInputEventData& other) {
3896 this->data.allowedMentions = other.allowedMentions;
3897 this->data.components = other.components;
3898 this->data.customId = other.customId;
3899 this->data.choices = other.choices;
3900 this->data.content = other.content;
3901 this->data.embeds = other.embeds;
3902 this->data.title = other.title;
3903 this->data.files = other.files;
3904 this->data.flags = other.flags;
3905 this->data.tts = other.tts;
3906 return *this;
3907 }
3908
3909 InteractionResponseData::InteractionResponseData(const RespondToInputEventData& other) {
3910 *this = other;
3911 }
3912
3913 InteractionResponseData::operator Jsonifier() {
3914 Jsonifier data{};
3915 data["type"] = this->type;
3916 if (this->data.attachments.size() > 0) {
3917 for (auto& value: this->data.attachments) {
3918 data["data"]["attachments"].emplaceBack(value);
3919 }
3920 }
3921 if (this->data.components.size() == 0) {
3922 data["data"]["components"].emplaceBack(ActionRowData{});
3923 data["data"]["components"].getValue<Jsonifier::ArrayType>().clear();
3924 } else {
3925 for (auto& value: this->data.components) {
3926 data["data"]["components"].emplaceBack(value);
3927 }
3928 }
3929 if (this->data.allowedMentions.parse.size() > 0 || this->data.allowedMentions.roles.size() > 0 ||
3930 this->data.allowedMentions.users.size() > 0) {
3931 data["data"]["allowed_mentions"] = this->data.allowedMentions.operator Jsonifier();
3932 }
3933 if (this->data.choices.size() > 0) {
3934 for (auto& value: this->data.choices) {
3935 Jsonifier valueNew{};
3936 valueNew["name"] = value.name;
3937 valueNew["name_localizations"] = value.nameLocalizations;
3938 valueNew["value"] = value.value;
3939 data["data"]["choices"].emplaceBack(value);
3940 }
3941 }
3942 if (this->data.embeds.size() == 0) {
3943 data["data"]["embeds"].emplaceBack(EmbedData{});
3944 data["data"]["embeds"].getValue<Jsonifier::ArrayType>().clear();
3945 } else {
3946 for (auto& value: this->data.embeds) {
3947 data["data"]["embeds"].emplaceBack(value);
3948 }
3949 }
3950 if (this->data.customId != "") {
3951 data["data"]["custom_id"] = this->data.customId;
3952 }
3953 if (this->data.content != "") {
3954 data["data"]["content"] = this->data.content;
3955 }
3956 if (this->data.title != "") {
3957 data["data"]["title"] = this->data.title;
3958 }
3959 data["data"]["flags"] = this->data.flags;
3960 data["data"]["tts"] = this->data.tts;
3961 return data;
3962 }
3963
3964 void parseCommandDataOption(std::unordered_map<std::string, JsonStringValue>& values, ApplicationCommandInteractionDataOption& data) {
3965 JsonStringValue valueNew{};
3966 valueNew.type = data.value.type;
3967 valueNew.value = data.value.value;
3968 values.insert_or_assign(data.name, valueNew);
3969 for (auto& value: data.options) {
3970 parseCommandDataOption(values, value);
3971 }
3972 }
3973
3974 CommandData& CommandData::operator=(const CommandData& other) noexcept {
3975 this->subCommandGroupName = other.subCommandGroupName;
3976 this->subCommandName = other.subCommandName;
3977 this->commandName = other.commandName;
3978 this->optionsArgs = other.optionsArgs;
3979 this->eventData = other.eventData;
3980 return *this;
3981 }
3982
3983 CommandData::CommandData(const CommandData& other) noexcept {
3984 *this = other;
3985 }
3986
3987 CommandData::CommandData(InputEventData inputEventData) {
3988 if (inputEventData.interactionData->data.applicationCommandData.name != "") {
3989 this->commandName = inputEventData.interactionData->data.applicationCommandData.name;
3990 }
3991 if (inputEventData.interactionData->data.messageInteractionData.targetId != 0) {
3992 this->optionsArgs.values.emplace("target_id",
3993 JsonStringValue{ .value = inputEventData.interactionData->data.messageInteractionData.targetId, .type = JsonType::String });
3994 } else if (inputEventData.interactionData->data.userInteractionData.targetId != 0) {
3995 this->optionsArgs.values.emplace("target_id",
3996 JsonStringValue{ .value = inputEventData.interactionData->data.userInteractionData.targetId, .type = JsonType::String });
3997 }
3998 this->eventData = inputEventData;
3999 for (auto& value: this->eventData.interactionData->data.applicationCommandData.options) {
4000 JsonStringValue valueNew{};
4001 valueNew.type = value.value.type;
4002 valueNew.value = value.value.value;
4003 this->optionsArgs.values.insert_or_assign(value.name, valueNew);
4004 parseCommandDataOption(this->optionsArgs.values, value);
4005 }
4006 for (auto& value: inputEventData.interactionData->data.applicationCommandData.options) {
4008 this->subCommandName = value.name;
4009 }
4011 this->subCommandGroupName = value.name;
4012 }
4013 }
4014 }
4015
4017 return *this->eventData.interactionData;
4018 }
4019
4021 return this->eventData.getGuildMemberData();
4022 }
4023
4025 return this->eventData.getChannelData();
4026 }
4027
4029 return this->eventData.getMessageData();
4030 }
4031
4033 return this->eventData.getGuildData();
4034 }
4035
4037 return this->eventData.getUserData();
4038 }
4039
4040 std::string CommandData::getCommandName() noexcept {
4041 return this->commandName;
4042 }
4043
4044 std::string CommandData::getSubCommandName() noexcept {
4045 return this->subCommandName;
4046 }
4047
4049 return this->subCommandGroupName;
4050 }
4051
4052 JsonifierValue CommandData::getCommandArguments() noexcept {
4053 return this->optionsArgs;
4054 }
4055
4057 return this->eventData;
4058 }
4059
4060 BaseFunctionArguments::BaseFunctionArguments(CommandData commanddataNew, DiscordCoreClient* discordCoreClientNew) : CommandData(commanddataNew) {
4061 this->discordCoreClient = discordCoreClientNew;
4062 }
4063
4064 MoveThroughMessagePagesData moveThroughMessagePages(const std::string& userID, InputEventData originalEvent, uint32_t currentPageIndex,
4065 const std::vector<EmbedData>& messageEmbeds, bool deleteAfter, uint32_t waitForMaxMs, bool returnResult) {
4066 MoveThroughMessagePagesData returnData{};
4067 uint32_t newCurrentPageIndex = currentPageIndex;
4068 StopWatch stopWatch{ Milliseconds{ waitForMaxMs } };
4069 auto createResponseData = std::make_unique<CreateInteractionResponseData>(originalEvent);
4070 auto interactionResponse = std::make_unique<RespondToInputEventData>(originalEvent);
4071 auto embedData = std::make_unique<EmbedData>();
4072 embedData->setColor("FEFEFE");
4073 embedData->setTitle("__**Permissions Issue:**__");
4074 embedData->setTimeStamp(getTimeAndDate());
4075 embedData->setDescription("Sorry, but that button can only be pressed by <@" + userID + ">!");
4076 createResponseData->addMessageEmbed(*embedData);
4077 createResponseData->setResponseType(InteractionCallbackType::Channel_Message_With_Source);
4078 if (messageEmbeds.size() > 0) {
4079 interactionResponse->addMessageEmbed(messageEmbeds[currentPageIndex]);
4080 }
4081 if (returnResult) {
4082 interactionResponse->addButton(false, "select", "Select", ButtonStyle::Success, "✅");
4083 }
4084 interactionResponse->addButton(false, "backwards", "Prev Page", ButtonStyle::Primary, "◀️");
4085 interactionResponse->addButton(false, "forwards", "Next Page", ButtonStyle::Primary, "▶️");
4086 interactionResponse->addButton(false, "exit", "Exit", ButtonStyle::Danger, "❌");
4087 interactionResponse->setResponseType(InputEventResponseType::Edit_Interaction_Response);
4088 originalEvent = InputEvents::respondToInputEventAsync(*interactionResponse).get();
4089 while (!stopWatch.hasTimePassed()) {
4090 std::this_thread::sleep_for(1ms);
4091 std::unique_ptr<ButtonCollector> button{ std::make_unique<ButtonCollector>(originalEvent) };
4092 std::vector<ButtonResponseData> buttonIntData{
4093 button->collectButtonData(false, waitForMaxMs, 1, *createResponseData, Snowflake{ stoull(userID) }).get()
4094 };
4095 std::unique_ptr<InteractionData> interactionData{ std::make_unique<InteractionData>() };
4096 if (buttonIntData.size() == 0 || buttonIntData.at(0).buttonId == "empty" || buttonIntData.at(0).buttonId == "exit") {
4097 std::unique_ptr<RespondToInputEventData> dataPackage02{ std::make_unique<RespondToInputEventData>(originalEvent) };
4098 if (buttonIntData.at(0).buttonId == "empty") {
4099 *dataPackage02 = originalEvent;
4100 } else {
4101 interactionData = std::make_unique<InteractionData>(buttonIntData.at(0));
4102 *dataPackage02 = RespondToInputEventData{ *interactionData };
4103 }
4104
4105 dataPackage02->addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
4106 for (size_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
4107 ActionRowData actionRow{};
4108 for (size_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
4109 auto component = originalEvent.getMessageData().components[x].components[y];
4110 component.disabled = true;
4111 actionRow.components.push_back(component);
4112 }
4113 dataPackage02->addComponentRow(actionRow);
4114 }
4115 if (deleteAfter == true) {
4116 InputEventData dataPackage03{ originalEvent };
4118 } else {
4119 dataPackage02->setResponseType(InputEventResponseType::Edit_Interaction_Response);
4120 InputEvents::respondToInputEventAsync(*dataPackage02).get();
4121 }
4122 MoveThroughMessagePagesData dataPackage03{};
4123 dataPackage03.inputEventData = originalEvent;
4124 dataPackage03.buttonId = "exit";
4125 return dataPackage03;
4126 } else if (buttonIntData.at(0).buttonId == "forwards" || buttonIntData.at(0).buttonId == "backwards") {
4127 if (buttonIntData.at(0).buttonId == "forwards" && (newCurrentPageIndex == (messageEmbeds.size() - 1))) {
4128 newCurrentPageIndex = 0;
4129 } else if (buttonIntData.at(0).buttonId == "forwards" && (newCurrentPageIndex < messageEmbeds.size())) {
4130 ++newCurrentPageIndex;
4131 } else if (buttonIntData.at(0).buttonId == "backwards" && (newCurrentPageIndex > 0)) {
4132 --newCurrentPageIndex;
4133 } else if (buttonIntData.at(0).buttonId == "backwards" && (newCurrentPageIndex == 0)) {
4134 newCurrentPageIndex = static_cast<uint32_t>(messageEmbeds.size()) - 1;
4135 }
4136 interactionData = std::make_unique<InteractionData>(buttonIntData.at(0));
4137 auto dataPackage = RespondToInputEventData{ *interactionData };
4138 dataPackage.setResponseType(InputEventResponseType::Edit_Interaction_Response);
4139 for (size_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
4140 ActionRowData actionRow{};
4141 for (size_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
4142 auto component = originalEvent.getMessageData().components[x].components[y];
4143 component.disabled = false;
4144 actionRow.components.push_back(component);
4145 }
4146 dataPackage.addComponentRow(actionRow);
4147 }
4148 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
4149 InputEvents::respondToInputEventAsync(dataPackage).get();
4150 } else if (buttonIntData.at(0).buttonId == "select") {
4151 if (deleteAfter == true) {
4152 InputEventData dataPackage03{ originalEvent };
4154 } else {
4155 std::unique_ptr<InteractionData> interactionData = std::make_unique<InteractionData>(buttonIntData.at(0));
4156 auto dataPackage = RespondToInputEventData{ *interactionData };
4157 dataPackage.setResponseType(InputEventResponseType::Edit_Interaction_Response);
4158 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
4159 for (size_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
4160 ActionRowData actionRow{};
4161 for (size_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
4162 auto component = originalEvent.getMessageData().components[x].components[y];
4163 component.disabled = true;
4164 actionRow.components.push_back(component);
4165 }
4166 dataPackage.addComponentRow(actionRow);
4167 }
4168 originalEvent = InputEvents::respondToInputEventAsync(dataPackage).get();
4169 }
4170 returnData.currentPageIndex = newCurrentPageIndex;
4171 returnData.inputEventData = originalEvent;
4172 returnData.buttonId = buttonIntData.at(0).buttonId;
4173 return returnData;
4174 }
4175 };
4176 return returnData;
4177 };
4178};
TimeFormat
Time formatting methods.
Definition: Utilities.hpp:1329
@ LongDateTime
"Tuesday, 20 April 2021 16:20" - Long Date/Time
ButtonStyle
Button styles.
GuildScheduledEventStatus
GuildScheduledEventStatus.
TriggerType
Trigger types for auto-moderation.
AuditLogEvent
Audit log events.
StickerFormatType
Sticker format types.
StageInstancePrivacyLevel
Stage instance privacy levels.
ApplicationCommandOptionType
Application command-option types.
GuildScheduledEventPrivacyLevel
Guild scheduled event privacy levels.
ComponentType
Component types.
SortOrderTypes
The sorting order, for Guild Forum channels.
InteractionType
Interaction types.
ChannelType
Channel types.
DiscordCoreAPI_Dll std::string getTimeAndDate()
Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
Definition: Utilities.cpp:1718
ApplicationCommandPermissionType
Application command permission-types.
PermissionOverwritesType
PermissionTypes overwrites types.
ActionType
Action types for auto-moderation.
ApplicationFlags
Application flags, for the ApplicationData structure.
GuildScheduledEventEntityType
Guild scheduled event entity types.
InputEventResponseType
Input event response types.
Definition: Utilities.hpp:906
EventType
Event types for auto-moderation.
ApplicationCommandType
Application command types.
ConnectionVisibilityTypes
Connection visibility types.
WebHookType
WebHook types.
MessageType
Message types.
MessageActivityType
Message activity types.
StickerType
Sticker types.
KeywordPresetType
Keyword preset types for auto-moderation.
StickerItemType
Sticker item types.
TextInputStyle
Text input style for modals.
@ Verified
Is it verified?
@ System
Is it a system integration?
@ MFAEnabled
Is MFA enabled?
@ Channel_Message_With_Source
Respond to an interaction with a message.
@ 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.
@ WidgetEnabled
Widget enabled.
@ Edit_Interaction_Response
Interaction response edit.
@ invisible
Invisible and shown as offline.
The main namespace for this library.
static ChannelData getCachedChannel(GetChannelData dataPackage)
Collects a Channel from the library's cache.
DiscordCoreClient - The main class for this library.
static BotUser getBotUser()
For collecting a copy of the current bot's User.
std::string getCreatedAtTimestamp(TimeFormat timeFormat)
Converts the snowflake-id into a time and date stamp.
std::string botId
What is the bot id?
std::string integrationId
What is the integration id?
Data structure representing a single User.
StringWrapper userName
The user's userName, not unique across the platform identify.
IconHash avatar
The user's avatar hash.
StringWrapper discriminator
The user's 4-digit discord-tag identify.
UserFlags flags
The public flags on a user' s account.
std::string proxyIconUrl
Proxy icon url.
std::string proxyIconUrl
Proxy icon url.
std::string value
The text on the field.
bool Inline
Is the field inline with the rest of them?
std::string name
The title of the field.
std::string url
Url for the embed.
EmbedData & setFooter(const std::string &footerText, const std::string &footerIconUrlText="")
Sets the footer's values for the embed.
EmbedData & setTitle(const std::string &titleNew)
Sets the title of the embed.
EmbedData & setImage(const std::string &imageUrl)
Sets the image of the embed.
EmbedProviderData provider
Embed provider data.
EmbedData & addField(const std::string &name, const std::string &value, bool Inline=true)
Adds a field to the embed.
std::string type
Type of the embed.
EmbedAuthorData author
Embed author data.
std::string description
Description of the embed.
EmbedThumbnailData thumbnail
Embed thumbnail data.
EmbedImageData image
Embed image data.
ColorValue hexColorValue
Hex color value of the embed.
std::string title
Title of the embed.
EmbedVideoData video
Embed video data.
EmbedData & setDescription(const std::string &descriptionNew)
Sets the description (the main contents) of the embed.
EmbedData & setColor(const std::string &hexColorValueNew)
Sets the color of the embed, by applying a hex-color value.
std::string timeStamp
Timestamp to be placed on the embed.
EmbedData & setThumbnail(const std::string &thumbnailUrl)
Sets the thumbnail of the embed.
EmbedData & setAuthor(const std::string &authorName, const std::string &authorAvatarUrl="")
Sets the author's name and avatar for the embed.
EmbedData & setTimeStamp(const std::string &timeStamp)
Sets the timeStamp on the embed.
std::vector< EmbedFieldData > fields
Array of embed fields.
EmbedFooterData footer
Embed footer data.
Snowflake guildId
Id of the Guild that the referenced Message was sent in.
Snowflake channelId
Id of the Channel that the referenced Message was sent in.
Snowflake messageId
Id of the Message to reference.
bool failIfNotExists
Fail if the Message doesn't exist?
Data representing a file to be sent via multipart-form data.
TimeStamp archiveTimestamp
(Where applicable) the time at which this Thread was archived.
int32_t autoArchiveDuration
How int64_t before archiving this Thread.
bool archived
Whether or not this Thread is currently archived.
bool invitable
The id of the individual who archived this Thread.
bool locked
Whether or not this Thread is currently locked.
TimeStamp joinTimestamp
The time at which the member joined this Thread.
Snowflake userId
The User id this voice state is for.
Snowflake channelId
The Channel id this User is connected to.
Snowflake guildId
The Guild id this voice state is for.
std::string sessionId
The session id for this voice state.
TimeStamp requestToSpeakTimestamp
The time at which the User requested to speak.
bool selfDeaf
Whether this User is locally deafened.
bool mute
Whether this User is muted by the server.
bool deaf
Whether this User is deafened by the server.
bool selfStream
Whether this User is streaming using "Go Live".
bool suppress
Whether this User is muted by the current User.
bool selfMute
Whether this User is locally muted.
bool selfVideo
Whether this User's camera is enabled.
Snowflake guildId
The id of the Guild that this Role is from.
Permissions permissions
The Role's base Guild Permissions.
StringWrapper name
The Role's name.
int16_t position
Its position amongst the rest of the Guild's roles.
ColorValue color
The Role's color.
StringWrapper unicodeEmoji
Emoji representing the Role.
RoleFlags flags
Role flags.
UserData user
User that created this emoji.
bool requireColons
Require colons to render it?
bool available
Is it available to be used?
std::vector< RoleData > roles
Roles that are allowed to use this emoji.
StringWrapper name
What is its name?
PresenceUpdateFlags theStatus
Current client status.
Snowflake guildId
Guild id for the current presence.
Data structure representing a single GuildMember.
GuildMemberFlags flags
GuildMember flags.
std::vector< Snowflake > roles
The Guild roles that they have.
IconHash avatar
This GuildMember's Guild Avatar.
TimeStamp joinedAt
When they joined the Guild.
StringWrapper nick
Their nick/display name.
Permissions permissions
Their base-level Permissions in the Guild.
Snowflake guildId
The current Guild's id.
uint64_t deny
Collection of Permissions to deny.
uint64_t allow
Collection of Permissions to allow.
PermissionOverwritesType type
Role or User type.
Data structure representing a single Channel.
std::vector< OverWriteData > permissionOverwrites
Permission overwrites.
uint16_t position
The position of the Channel, in the Guild's Channel list.
Snowflake ownerId
Id of the Channel's owner.
SortOrderTypes defaultSortOrder
Default sorting order for a forum thread.
Snowflake parentId
Id of the Channel's parent Channel/category.
ChannelFlags flags
Flags combined as a bitmask.
ChannelType type
The type of the Channel.
uint32_t memberCount
Count of members active in the Channel.
Snowflake guildId
Id of the Channel's Guild, if applicable.
StringWrapper name
Name of the Channel.
int64_t durationSeconds
Timeout duration in seconds.
Snowflake channelId
Channel to which user content should be logged.
int32_t mentionTotalLimit
Total number of unique role and user mentions allowed per message (Maximum of 50).
std::vector< std::string > allowList
Substrings which will be exempt from triggering the preset trigger type.
std::vector< std::string > keywordFilter
Substrings which will be searched for in content.keyword_filter array of strings.
std::vector< KeywordPresetType > presets
The internally pre-defined wordsets which will be searched for in content.
ActionType type
The type of action.
ActionMetaData metadata
Additional metadata needed during execution for this specific action type.
std::vector< Snowflake > exemptChannels
The channel ids that should not be affected by the rule(Maximum of 50).
EventType eventType
The rule event type.
TriggerMetaData triggerMetaData
The rule trigger metadata actions array of action objects the.
TriggerType triggerType
The rule trigger type.
std::vector< Snowflake > exemptRoles
The role ids that should not be affected by the rule(Maximum of 20).
Snowflake creatorId
The user which first created this rule.
std::vector< ActionData > actions
Actions which will execute when the rule is triggered.
Snowflake guildId
The guild which this rule belongs to.
bool enabled
Whether the rule is enabled.
ApplicationCommandPermissionType type
The type of PermissionTypes.
bool permission
Whether the PermissionTypes is active or not.
std::vector< ApplicationCommandPermissionData > permissions
The Permissions.
bool me
Whether or not I (The bot) placed it.
Snowflake messageId
The id of the Message upon which it was placed.
Snowflake guildId
The id of the Guild where it was placed.
EmojiData emoji
The emoji that was placed as a reaction.
Snowflake channelId
The id of the Channel where it was placed.
GuildMemberData member
The GuildMember who placed the reaction.
Snowflake userId
The id of the User who placed the reaction.
int32_t count
The number of times this particular emoji was placed as a reaction to the given Message.
bool optimal
True for a single server that is closest to the current User's client.
bool custom
Whether this is a custom voice region(used for events / etc).
bool deprecated
Whether this is a deprecated voice region(avoid switching to these).
std::string name
Name of the region.
MessageActivityType type
Message activity type.
std::string reason
Reason for the ban.
UserData user
User that was banned.
std::vector< Permissions > permissions
Permissions for the team.
UserData user
User data of the current User.
Snowflake teamId
Id of the current team.
std::vector< TeamMembersObjectData > members
Array of team members object data.
std::string icon
Icon for the team.
Snowflake ownerUserId
User id of the team owner.
std::vector< std::string > scopes
The scopes to add the application to the server with.
Permissions permissions
The permissions to request for the bot role.
std::string coverImage
The cover image.
InstallParamsData params
Settings for the application's default in-app authorization link, if enabled.
UserData owner
Application's owner.
std::vector< std::string > tags
Up to 5 tags describing the content and functionality of the application install_params.
TeamObjectData team
Team object data.
std::string icon
Application's icon.
std::string termsOfServiceUrl
Terms of service Url.
std::string privacyPolicyUrl
Privacy policy Url.
std::string verifyKey
The verification key.
bool botRequireCodeGrant
Does the bot require a code grant?
std::string primarySkuId
Primary SKU Id.
ApplicationFlags flags
Application flags.
std::string name
Application's name.
std::string description
Description of the application.
std::vector< std::string > rpcOrigins
Array of RPC origin strings.
std::string summary
Summary of the application.
std::string expires
When the access token expires.
std::vector< std::string > scopes
Array of strings - the scopes the User has authorized the application for.
AuthorizationInfoData() noexcept=default
The User who has authorized, if the User has authorized with the identify scope.
ApplicationData application
Partial application object the current application.
std::string name
Name of the account.
Snowflake channelId
The widget Channel id.
bool enabled
Whether the widget is enabled.
UserData user
User data for the integration.
int32_t subscriberCount
Number of current subscribers.
TimeStamp syncedAt
Time it was last synced at.
int32_t expireBehavior
What to do upon expiry.
ApplicationData application
Application data.
std::string type
Type of integration.
int32_t expireGracePeriod
How int64_t before the integration expires.
bool enableEmoticons
Emoticons enabled?
std::string name
Name of the integration.
std::string membersRemoved
Number of members that were removed upon a prune.
std::string deleteMemberDays
Number of days for which the member's Messages were deleted.
std::string key
The key of the audit log change.
OptionalAuditEntryInfoData options
Audit log entry info data.
Snowflake targetId
Id of the target User.
TimeStamp createdTimeStamp
Time at which this entry was created.
Snowflake userId
Id of the executing User.
AuditLogEvent actionType
Audit log action type.
std::string reason
The reason that was entered for the given change.
std::vector< AuditLogChangeData > changes
Array of audit log change data.
std::string description
Description of the welcome Channel.
Snowflake emojiId
Emoji id for the Channel.
Snowflake channelId
Id of the welcome Channel.
std::string emojiName
Emoji name for the Channel.
std::vector< WelcomeScreenChannelData > welcomeChannels
Welcome screen Channel data.
std::string description
Description of the welcome screen.
Snowflake guildId
The Guild id for which the Channel exists in.
bool discoverableDisabled
Is it discoverable?
std::string topic
The topic of the StageInstance.
StageInstancePrivacyLevel privacyLevel
Privacy level of the Channel.
Snowflake channelId
The Channel's id.
int32_t sortValue
Where in the stack of stickers it resides.
UserData user
The User that uploaded the Guild Sticker.
std::string packId
Pack id of the Sticker.
StickerType type
The type of Sticker.
std::string asset
Asset value for the Sticker.
StickerFormatType formatType
Format type.
Snowflake guildId
The Guild id for which the Sticker exists in.
std::string name
The Sticker's name.
std::string description
Description of the Sticker.
StickerFlags flags
Sticker flags.
Data structure representing a single Guild.
std::vector< Snowflake > stickers
Array of Guild channels.
StringWrapper name
The Guild's name.
std::vector< Snowflake > members
Array of GuildMembers.
std::vector< Snowflake > emoji
Array of Guild channels.
std::vector< PresenceUpdateData > presences
Presence states for each of the GuildMembers..
TimeStamp joinedAt
When the bot joined this Guild.
std::vector< Snowflake > guildScheduledEvents
Array of Guild channels.
IconHash icon
Url to the Guild's icon.
DiscordCoreClient * discordCoreClient
A pointer to the DiscordCoreClient.
std::vector< Snowflake > threads
Array of Guild channels.
uint32_t memberCount
Member count.
VoiceConnection * connectToVoice(const Snowflake guildMemberId, const Snowflake channelId=Snowflake{}, bool selfDeaf=false, bool selfMute=false, StreamInfo streamInfo=StreamInfo{})
For connecting to an individual voice channel.
Snowflake ownerId
User id of the Guild's owner.
std::vector< Snowflake > stageInstances
Array of Guild channels.
std::vector< Snowflake > channels
Array of Guild channels.
VoiceConnection * voiceConnectionPtr
A pointer to the VoiceConnection, if present.
GuildFlags flags
Guild flags.
std::vector< Snowflake > roles
Array of Guild roles.
Snowflake guildId
The Guild id which the scheduled event belongs to.
Snowflake channelId
The Channel id in which the scheduled event will be hosted, or null if scheduled entity type is Exter...
Snowflake creatorId
The id of the User that created the scheduled event *.
std::string description
The description of the scheduled event(1 - 1000 characters.
std::string scheduledEndTime
The time the scheduled event will end, required if entity_type is External.
Snowflake entityId
The id of an entity associated with a Guild scheduled event.
uint32_t userCount
The number of users subscribed to the scheduled event.
GuildScheduledEventPrivacyLevel privacyLevel
The privacy level of the scheduled event.
GuildScheduledEventEntityType entityType
The type of the scheduled event.
UserData creator
The User that created the scheduled event.
GuildScheduledEventStatus status
The status of the scheduled event.
std::string scheduledStartTime
The time the scheduled event will start.
std::string name
The name of the scheduled event(1 - 100 characters).
GuildScheduledEventMetadata entityMetadata
Additional metadata for the Guild scheduled event.
Snowflake guildScheduledEventId
The scheduled event id which the User subscribed to/.
UserData user
User which subscribed to an event.
GuildMemberData member
Guild member data for this User for the Guild which this event belongs to, if any.
GuildScheduledEventData guildScheduledEvent
Scheduled Guild event.
int32_t maxUses
Max number of uses.
int32_t maxAge
Maximum age of the invite.
StageInstanceData stageInstance
Stage instance data.
int32_t approximatePresenceCount
Approximate presence count.
ApplicationData targetApplication
Application data.
UserData inviter
The User who created the invite.
int32_t approximateMemberCount
Approximate member count.
GuildData guild
Guild data of the Channel that the invite is for.
TimeStamp expiresAt
When the invite expires.
Snowflake guildId
The Guild this invite is for.
UserData targetUser
Target User of the invite.
TimeStamp createdAt
Time it was created at.
std::string code
Unique invite code.
ChannelData channel
Channel data of the Channel that the invite is for.
int32_t uses
The current number of uses.
UserData creator
The User who created the template.
std::string description
The description for the template.
std::string code
The template code(unique ID).
std::string updatedAt
When this template was last synced to the source Guild.
GuildData serializedSourceGuild
The Guild snapshot this template contains.
uint32_t usageCount
Number of times this template has been used.
std::string createdAt
When this template was created.
std::string creatorId
The ID of the User who created the template.
bool isDirty
Whether the template has unsynced changes.
std::string sourceGuildId
The ID of the Guild this template is based on.
std::string name
Name of the WebHook.
WebHookType type
Type of WebHook.
GuildData sourceGuild
Source Guild id.
std::string url
Url of the WebHook.
Snowflake channelId
Channel id for which the WebHook was issued.
Snowflake applicationId
Application id.
std::string avatar
Avatar of the WebHook.
std::string token
Token of the WebHook.
Snowflake guildId
Guild id for which the WebHook was issued.
UserData user
User which create the WebHook.
ChannelData sourceChannel
Channel for which th WebHook was issued.
std::vector< IntegrationData > integrations
Array of partial integration objects.
std::vector< UserData > users
Array of user objects.
std::vector< AuditLogEntryData > auditLogEntries
Array of audit log entry objects.
std::vector< GuildScheduledEventData > guildScheduledEvents
Array of guild scheduled event objects.
std::vector< ChannelData > threads
Array of thread-specific channel objects.
std::vector< WebHookData > webhooks
Array of webhook objects.
std::vector< AutoModerationRuleData > autoModerationRules
List of auto moderation rules referenced in the audit log.
Data structure representing an ApplicationCommand's option choice.
std::unordered_map< std::string, std::string > nameLocalizations
Dictionary with keys in available locales Localization dictionary for the name field.
std::string name
The name of the current choice.
std::string name
Name of the current ApplicationCommand option.
std::unordered_map< std::string, std::string > nameLocalizations
Dictionary for the name localizations field.
int32_t maxValue
If the option is an INTEGER or NUMBER type, the maximum value permitted.
std::string description
A description of the current ApplicationCommand option.
bool autocomplete
If autocomplete interactions are enabled for this STRING, INTEGER, or NUMBER type option.
std::vector< ChannelType > channelTypes
Set when the ApplicationCommand option type is set to Channel.
int32_t minValue
If the option is an INTEGER or NUMBER type, the minimum value permitted.
bool required
If the parameter is required or optional– default false.
ApplicationCommandOptionType type
The type of command option.
std::vector< ApplicationCommandOptionData > options
A vector of possible options for the current ApplicationCommand option.
std::vector< ApplicationCommandOptionChoiceData > choices
A vector of possible choices for the current ApplicationCommand option.
std::unordered_map< std::string, std::string > descriptionLocalizations
Dictionary for the description localizations field.
ComponentType componentType
The type of component.
std::string customId
The custom id of the Interaction entity.
std::vector< std::string > values
The values of the components.
std::string customId
The custom id of the Interaction entity.
std::string customIdSmall
The custom id of a particular modal input.
std::string value
The input value of the modal.
Allowable mentions for a Message.
std::vector< std::string > users
Array of user_ids to mention (Max size of 100)
bool repliedUser
For replies, whether to mention the author of the Message being replied to (default false).
std::vector< std::string > parse
A vector of allowed mention types to parse from the content.
std::vector< std::string > roles
Array of role_ids to mention (Max size of 100)
std::string description
Description of the select-menu-option.
std::string value
A value for identifying the option.
EmojiData emoji
An optional emoji to put on it.
bool _default
Is it the default option?
std::string label
A visible label for the select-menu-option.
Represents a single Message-component.
int32_t style
One of ButtonStyle, or TextInputStyle.
bool required
Whether this component is required to be filled.
std::string label
The label for this component.
EmojiData emoji
Emoji name, id, and animated.
int32_t minLength
The minimum input length for a text input.
ComponentType type
Integer component type.
std::string title
Url, for url types.
bool disabled
Whether the component is disabled, default false.
int32_t maxLength
The maximum input length for a text input.
std::string placeholder
Custom placeholder text if nothing is selected, max 100 characters.
std::string url
Url, for url types.
std::string value
A pre-filled value for this component.
std::vector< ChannelType > channelTypes
Array of channel types List of channel types to include in the channel select component (type 8).
int32_t maxValues
The maximum number of items that can be chosen; default 1, max 25.
std::vector< SelectOptionData > options
Aray of select options the choices in the select, max 25.
int32_t minValues
The minimum number of items that must be chosen; default 1, min 0, max 25.
std::string customId
A developer-defined identifier for the component, max 100 characters.
Action row data of Message components.
std::vector< ComponentData > components
Array of components to make up the action-row.
std::string customId
A developer-defined identifier for the component, max 100 characters.
std::vector< ApplicationCommandOptionChoiceData > choices
Autocomplete choices(max of 25 choices).
std::vector< EmbedData > embeds
Message embeds.
std::vector< ActionRowData > components
Message components.
std::vector< File > files
Files for uploading.
AllowedMentionsData allowedMentions
Allowed mentions data.
std::string title
The title of the popup modal.
ApplicationCommandType type
The type of ApplicationCommand.
bool dmPermission
Indicates whether the command is available in DMs with the app, only for globally - scoped commands.
std::string description
A description of the current ApplicationCommand.
std::string version
An autoincremented version.
std::string name
Name of the current ApplicationCommand.
std::unordered_map< std::string, std::string > nameLocalizations
Dictionary with keys in available locales.
Snowflake applicationId
The current application id.
std::vector< ApplicationCommandOptionData > options
A vector of possible options for the current ApplicationCommand.
Permissions defaultMemberPermissions
Set of permissions represented as a bit set all.
std::unordered_map< std::string, std::string > descriptionLocalizations
Dictionary with keys in available locales.
std::string name
The name of the Channel that was mentioned.
Snowflake guildId
The id of the Guild where it took place.
ChannelType type
The type of Channel that was mentioned.
TimeStamp lastPinTimeStamp
The time of the last pinned Message.
Snowflake guildId
The id of the Guild within which the Message was pinned.
Snowflake channelId
The id of the Channel within which the Message was pinned.
Snowflake guildId
The id of the Guild for which the threads are being synced.
std::vector< ChannelData > threads
All active threads in the given channels that the current User can access.
std::vector< ThreadMemberData > members
Array of members that are a part of the Thread.
std::vector< std::string > channelIds
The parent Channel ids whose threads are being synced.
std::vector< ThreadMemberData > addedMembers
New members added to the Thread.
uint32_t memberCount
Number of Guild-members in the Thread.
Snowflake guildId
Guild id of the Thread.
std::vector< std::string > removedMemberIds
Members who have been removed.
std::string name
The name of the Sticker.
StickerItemType formatType
Message Sticker item type.
TimeStamp editedTimestamp
The time at which it was edited.
std::vector< std::string > mentionRoles
std::vector of "mention roles" ids.
std::vector< UserData > mentions
Array of User data, for individual's that were mentioned.
bool mentionEveryone
Does the Message mention everyone?
Snowflake webHookId
WebHook id of the Message, if applicable.
MessageInteractionData interaction
Message Interaction data.
MessageReferenceData messageReference
Message reference data.
ChannelData thread
The Thread that the Message was sent in, if applicable.
TimeStamp timeStamp
The timeStamp of when the Message was created.
GuildMemberData member
The author's Guild member data.
std::string content
The Message's content.
Snowflake channelId
The Channel it was sent in.
Snowflake guildId
The id of the Guild the Message was sent in.
std::vector< StickerItemData > stickerItems
Array of Message Sticker item data.
std::vector< ChannelMentionData > mentionChannels
array of Channel mention data.
UserData author
The author's User data.
std::vector< ActionRowData > components
Array of action row data.
std::vector< AttachmentData > attachments
Array of attachment data.
std::vector< EmbedData > embeds
Array of Message embeds.
std::vector< StickerData > stickers
Array of Message Sticker data.
Snowflake applicationId
Application id.
bool tts
Is it a text-to-speech Message?
ApplicationData application
Application data.
MessageActivityData activity
Message activity data.
Data structure representing a single Message.
std::unique_ptr< MessageDataOld > referencedMessage
The referenced Message, to reply to.
std::unordered_map< uint64_t, UserData > users
std::map full of UserData.
std::unordered_map< uint64_t, MessageData > messages
std::map full of messageData->
std::unordered_map< uint64_t, AttachmentData > attachments
std::map of Snowflakes to attachment objects the ids and attachment objects.
std::unordered_map< uint64_t, RoleData > roles
std::map full of RoleData.
std::unordered_map< uint64_t, ChannelData > channels
std::map full of ChannelData.
std::unordered_map< uint64_t, GuildMemberData > members
std::map full of GuildMemeberData.
std::string coverStickerId
Id of a Sticker in the pack which is shown as the pack's icon.
std::string name
Name of the Sticker pack.
std::string skuId
Id of the pack's SKU.
Snowflake Id
Id of the Sticker pack.
std::string description
Description of the Sticker pack.
std::vector< StickerData > stickers
Array of Sticker objects the stickers in the pack.
std::string bannerAssetId
Id of the Sticker pack's banner image.
std::vector< IntegrationData > integrations
An array of partial server integrations.
bool friendSync
Whether friend sync is enabled for this connection.
std::string name
The userName of the connection account.
std::string type
The service of the connection(twitch, youtube).
bool verified
Whether the connection is verified.
ConnectionVisibilityTypes visibility
Visibility of this connection.
bool revoked
Whether the connection is revoked.
bool showActivity
Whether activities related to this connection will be shown in presence updates.
std::vector< ApplicationCommandInteractionDataOption > options
ApplicationCommand Interaction data options.
ApplicationCommandOptionType type
The type of ApplicationCommand options.
std::string name
The name of the current option.
bool focused
True if this option is the currently focused option for autocomplete.
JsonStringValue value
The value if it's an int32_t.
Snowflake guildId
The guild that the command took place in.
std::vector< ApplicationCommandInteractionDataOption > options
ApplicationCommand Interaction data options.
ApplicationCommandType type
The type of ApplicationCommand.
ApplicationCommandInteractionData applicationCommandData
ApplicationCommand Interaction data.
MessageCommandInteractionData messageInteractionData
Message command Interaction data.
UserCommandInteractionData userInteractionData
User command Interaction data.
ComponentInteractionData componentData
Component Interaction data.
ModalInteractionData modalData
Modal Interaction data.
Snowflake guildId
The Guild id of the Guild it was sent in.
InteractionDataData data
The Interaction's data.
MessageData message
The Message that the Interaction came through on, if applicable.
Snowflake applicationId
The application's id.
std::string guildLocale
The guild's preferred locale, if invoked in a guild.
std::string token
The Interaction token.
UserData user
The User data of the sender of the Interaction.
InteractionType type
The type of Interaction.
int32_t version
The Interaction version.
std::string locale
The selected language of the invoking user.
GuildMemberData member
The data of the Guild member who sent the Interaction, if applicable.
Snowflake channelId
The Channel the Interaction was sent in.
Permissions appPermissions
Bitwise set of permissions the app or bot has within the channel the interaction was sent from.
uint32_t maxConcurrency
The number of identify requests allowed per 5 seconds.
uint32_t total
The total number of session starts the current User is allowed.
uint32_t resetAfter
The number of Milliseconds after which the limit resets.
uint32_t remaining
The remaining number of session starts the current User is allowed.
uint32_t shards
The recommended number of shards to use when connecting.
SessionStartData sessionStartLimit
Information on the current session start limit.
std::string url
The WSS Url that can be used for connecting to the gateway.
Data representing an input-event, which is any Message or Interaction that is coming into the bot as ...
GuildData getGuildData() const
Returns the Guild of this input-event.
MessageData getMessageData() const
Returns the Message data, if applicable, of this input-event.
UserData getUserData() const
Returns the User of this input-event.
ChannelData getChannelData() const
Returns the Channel of this input-event.
GuildMemberData getGuildMemberData() const
Returns the GuildMember of this input-event.
InteractionData getInteractionData() const
Returns the Interaction data, if appplicable, of this input-event.
Data for responding to an input-event.
RespondToInputEventData & addFile(File theFile)
Adds a file to the current collection of files for this message response.
RespondToInputEventData & setResponseType(InputEventResponseType typeNew)
For setting the type of response to make.
RespondToInputEventData & addSelectMenu(bool disabled, const std::string &customIdNew, std::vector< SelectOptionData > options, const std::string &placeholder, int32_t maxValues, int32_t minValues, SelectMenuType type, std::vector< ChannelType > channelTypes=std::vector< ChannelType >{})
Adds a select-menu to the response Message.
InputEventResponseType type
The type of response to make.
RespondToInputEventData & setTTSStatus(bool enabledTTs)
For setting the tts status of a response.
RespondToInputEventData & addContent(const std::string &dataPackage)
For setting the Message content in a response.
RespondToInputEventData & setTargetUserID(const Snowflake targetUserIdNew)
For setting the direct-Message User target of a response.
RespondToInputEventData & addAllowedMentions(AllowedMentionsData dataPackage)
For setting the allowable mentions in a response.
RespondToInputEventData & addComponentRow(ActionRowData dataPackage)
For setting the components in a response.
RespondToInputEventData & setAutoCompleteChoice(Jsonifier value, const std::string &theName, std::unordered_map< std::string, std::string > theNameLocalizations)
For setting the choices of an autocomplete response.
RespondToInputEventData & addModal(const std::string &topTitleNew, const std::string &topCustomIdNew, const std::string &titleNew, const std::string &customIdNew, bool required, int32_t minLength, int32_t maxLength, TextInputStyle inputStyle, const std::string &label="", const std::string &placeholder="")
Adds a modal to the response Message.
RespondToInputEventData & addMessageEmbed(EmbedData dataPackage)
For setting the embeds in a response.
RespondToInputEventData & addButton(bool disabled, const std::string &customIdNew, const std::string &buttonLabel, ButtonStyle buttonStyle, const std::string &emojiName="", Snowflake emojiId=Snowflake{}, const std::string &url="")
Adds a button to the response Message.
Message response base, for responding to messages.
MessageResponseBase & addContent(const std::string &dataPackage)
For setting the Message content in a response.
MessageResponseBase & addModal(const std::string &topTitleNew, const std::string &topCustomIdNew, const std::string &titleNew, const std::string &customIdNew, bool required, int32_t minLength, int32_t maxLength, TextInputStyle inputStyle, const std::string &label="", const std::string &placeholder="")
Adds a modal to the response Message.
MessageResponseBase & addMessageEmbed(EmbedData dataPackage)
For setting the embeds in a response.
MessageResponseBase & addFile(File theFile)
Adds a file to the current collection of files for this message response.
MessageResponseBase & setTTSStatus(bool enabledTTs)
For setting the tts status of a response.
MessageResponseBase & addAllowedMentions(AllowedMentionsData dataPackage)
For setting the allowable mentions in a response.
MessageResponseBase & addComponentRow(ActionRowData dataPackage)
For setting the components in a response.
MessageResponseBase & addButton(bool disabled, const std::string &customIdNew, const std::string &buttonLabel, ButtonStyle buttonStyle, const std::string &emojiName="", Snowflake emojiId=Snowflake{}, const std::string &url="")
Adds a button to the response Message.
MessageResponseBase & addSelectMenu(bool disabled, const std::string &customIdNew, std::vector< SelectOptionData > options, const std::string &placeholder, int32_t maxValues, int32_t minValues, SelectMenuType type, std::vector< ChannelType > channelTypes=std::vector< ChannelType >{})
Adds a select-menu to the response Message.
InteractionCallbackData data
Interaction ApplicationCommand callback data.
std::string thumbnailUrl
The Url of the thumbnail image of this Song.
std::string duration
The duration of the Song.
std::string viewUrl
The url for listening to this Song through a browser.
std::string description
A description of the Song.
std::string songTitle
The title of the Song.
Command data, for functions executed by the CommandController.
MessageData getMessageData() noexcept
Returns the Message data, if applicable, of this input-event.
std::string getCommandName() noexcept
Returns the name of this entered command.
GuildData getGuildData() noexcept
Returns the Guild of this input-event.
GuildMemberData getGuildMemberData() noexcept
Returns the GuildMember of this input-event.
InputEventData getInputEventData() noexcept
Returns the InputEventData for this command.
InteractionData getInteractionData() noexcept
Returns the Interaction data, if appplicable, of this input-event.
std::string getSubCommandName() noexcept
Returns the subcommand-name of this entered command.
ChannelData getChannelData() noexcept
Returns the Channel of this input-event.
UserData getUserData() noexcept
Returns the User of this input-event.
JsonifierValue getCommandArguments() noexcept
Returns the collection of command inputs/options for this command.
std::string getSubCommandGroupName() noexcept
Returns the subcommand-name of this entered command group.
static GuildData getCachedGuild(GetGuildData dataPackage)
Collects a Guild from the library's cache.
static GuildMemberData getCachedGuildMember(GetGuildMemberData dataPackage)
Collects a GuildMember from the library's cache.
static CoRoutine< void > deleteInputEventResponseAsync(InputEventData &dataPackage, int32_t timeDelayNew=0)
Deletes a previously sent "input-event-response".
static CoRoutine< InputEventData > respondToInputEventAsync(RespondToInputEventData dataPackage)
Responds to one of a number of types of "InputEvents".
Definition: InputEvents.cpp:32
void updateVoiceStatus(UpdateVoiceStateData &datdataPackageaPackage)
Updates the bot's current voice-status. Joins/leaves a Channel, and/or self deafens/mutes.
static UserData getCachedUser(GetUserData dataPackage)
Collects a given User from the library's cache.
For connecting two bots to stream the VC contents between the two.
Definition: Utilities.hpp:643
AudioFrameType type
The type of audio frame.
Definition: Utilities.hpp:1285
std::basic_string< std::byte > data
The audio data.
Definition: Utilities.hpp:1286
int64_t currentSize
The current size of the allocated memory.
Definition: Utilities.hpp:1288
uint64_t guildMemberId
GuildMemberId for the sending GuildMember.
Definition: Utilities.hpp:1287
For connecting to a voice-channel. "streamInfo" is used when a socket is created to connect this bot ...
Definition: Utilities.hpp:1311
int32_t currentShard
The current websocket shard, if applicable.
Definition: Utilities.hpp:1313
Class for representing a timeStamp, as well as working with time-related values.
Definition: Utilities.hpp:1576
VoiceConnection class - represents the connection to a given voice Channel.