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