47 namespace discord_core_internal {
49 websocket_resume_data::operator discord_core_internal::etf_serializer() {
50 etf_serializer data{};
51 data[
"seq"] = lastNumberReceived;
52 data[
"session_id"] = sessionId;
53 data[
"token"] = botToken;
57 websocket_identify_data::operator discord_core_internal::etf_serializer() {
58 etf_serializer serializer{};
59 serializer[
"intents"] = intents;
60 serializer[
"large_threshold"] = 250;
61 serializer[
"presence"] = presence.operator discord_core_internal::etf_serializer();
62 serializer[
"properties"][
"browser"] =
"DiscordCoreAPI";
63 serializer[
"properties"][
"device"] =
"DiscordCoreAPI";
64 serializer[
"properties"][
"os"] = properties.os;
65 serializer[
"shard"].emplaceBack(shard.at(0));
66 serializer[
"shard"].emplaceBack(shard.at(1));
67 serializer[
"token"] = botToken;
71 https_workload_data& https_workload_data::operator=(https_workload_data&& other)
noexcept {
73 headersToInsert = std::move(other.headersToInsert);
74 relativePath = std::move(other.relativePath);
75 callStack = std::move(other.callStack);
76 baseUrl = std::move(other.baseUrl);
77 content = std::move(other.content);
78 workloadClass = other.workloadClass;
79 workloadType = other.workloadType;
80 payloadType = other.payloadType;
85 https_workload_data::https_workload_data(https_workload_data&& other)
noexcept {
86 *
this = std::move(other);
89 https_workload_data& https_workload_data::operator=(https_workload_type type) {
94 https_workload_type https_workload_data::getWorkloadType()
const {
98 https_workload_data::https_workload_data(https_workload_type type) {
103 update_presence_data::operator discord_core_internal::etf_serializer() {
104 discord_core_internal::etf_serializer data{};
105 for (
auto& value: activities) {
106 discord_core_internal::etf_serializer newData{};
107 if (value.url !=
"") {
108 newData[
"url"] = value.url;
110 if (value.state !=
"") {
111 newData[
"state"] = value.state;
113 newData[
"name"] = value.name;
114 newData[
"type"] = value.type;
115 data[
"activities"].emplaceBack(newData);
117 data[
"status"] = statusReal;
118 data[
"since"] = since;
123 update_voice_state_data::operator discord_core_internal::etf_serializer() {
124 discord_core_internal::etf_serializer data{};
125 if (channelId == 0) {
126 data[
"channel_id"] = discord_core_internal::json_type::null_t;
128 data[
"channel_id"] = channelId.operator jsonifier::string();
130 data[
"self_deaf"] = selfDeaf;
131 data[
"self_mute"] = selfMute;
132 data[
"guild_id"] = guildId.operator jsonifier::string();
136 update_voice_state_data_dc::operator discord_core_internal::etf_serializer() {
137 discord_core_internal::etf_serializer data{};
138 data[
"channel_id"] = discord_core_internal::json_type::null_t;
139 data[
"self_deaf"] = selfDeaf;
140 data[
"self_mute"] = selfMute;
141 data[
"guild_id"] = guildId.operator jsonifier::string();
145 voice_state_data_light guild_member_data::getVoiceStateData() {
149 user_cache_data guild_member_data::getUserData() {
157 voice_state_data_light guild_member_cache_data::getVoiceStateData() {
161 user_cache_data guild_member_cache_data::getUserData() {
169 bool guild_cache_data::areWeConnected() {
170 return getDiscordCoreClient()->getVoiceConnection(
id).areWeConnected();
176 data.selfDeaf =
false;
177 data.selfMute =
false;
179 discord_core_client::getSongAPI(
id).disconnect();
181 discord_core_client::getVoiceConnection(
id).disconnect();
184 bool guild_data::areWeConnected() {
185 return getDiscordCoreClient()->getVoiceConnection(
id).areWeConnected();
189 discord_core_internal::websocket_message_data<update_voice_state_data> data{};
190 data.excludedKeys.emplace(
"t");
191 data.excludedKeys.emplace(
"s");
192 data.d.channelId = 0;
193 data.d.selfDeaf =
false;
194 data.d.selfMute =
false;
196 discord_core_client::getSongAPI(
id).disconnect();
198 discord_core_client::getVoiceConnection(
id).disconnect();
238 for (uint64_t x = 0; x < rhs.
choices.size(); ++x) {
259 timeStamp =
static_cast<jsonifier::string
>(timeStampNew);
268 fields.emplace_back(field);
278 hexColorValue = jsonifier::strToUint64<16>(
static_cast<jsonifier::string
>(hexColorValueNew));
297 void embed_image_data::generateExcludedKeys() {
309 void embed_author_data::generateExcludedKeys() {
324 void embed_data::generateExcludedKeys() {
346 author.generateExcludedKeys();
368 auto audit_log_data::getAuditLogData(
const snowflake userIdOfChanger,
audit_log_event auditLogType) {
370 if (value.id == userIdOfChanger && value.actionType == auditLogType) {
374 return audit_log_entry_data();
377 auto audit_log_data::getAuditLogData(
audit_log_event auditLogType,
const snowflake userIdOfTarget) {
379 if (value.targetId == userIdOfTarget && value.actionType == auditLogType) {
383 return audit_log_entry_data();
386 void partial_emoji_data::generateExcludedKeys() {
395 void emoji_data::generateExcludedKeys() {
405 if (
roles.size() == 0) {
413 bool application_command_data::operator==(
const application_command_data& rhs)
const {
417 if (
name != rhs.name) {
420 if (
type != rhs.type) {
423 if (
options.size() != rhs.options.size()) {
426 for (uint64_t x = 0; x <
options.size(); ++x) {
427 if (
options.at(x) != rhs.options.at(x)) {
434 bool application_command_option_choice_data::operator==(
const application_command_option_choice_data& rhs)
const {
435 if (
name != rhs.name) {
441 if (
value != rhs.value) {
447 input_event_data& input_event_data::operator=(input_event_data&& other)
noexcept {
448 if (
this != &other) {
449 interactionData = std::move(other.interactionData);
450 interactionData.member.guildId = interactionData.guildId;
451 responseType = other.responseType;
456 input_event_data::input_event_data(input_event_data&& other)
noexcept {
457 *
this = std::move(other);
460 input_event_data& input_event_data::operator=(
const input_event_data& other) {
461 if (
this != &other) {
462 interactionData = other.interactionData;
463 interactionData.member.
guildId = interactionData.guildId;
469 input_event_data::input_event_data(
const input_event_data& other) {
473 input_event_data& input_event_data::operator=(
const interaction_data& other) {
474 interactionData = other;
475 interactionData.member.
guildId = interactionData.guildId;
479 input_event_data::input_event_data(
const interaction_data& interactionData) {
480 *
this = interactionData;
484 if (interactionData.member.
user.
id != 0) {
485 return interactionData.member.
user;
487 return interactionData.user;
492 return interactionData.channel;
496 return interactionData.member;
499 void interaction_callback_data::generateExcludedKeys() {
504 for (
auto& value02: value.components) {
505 value02.generateExcludedKeys();
508 for (
auto& value:
embeds) {
509 value.generateExcludedKeys();
526 if (
files.size() == 0) {
534 void action_row_data::generateExcludedKeys() {
536 excludedKeys.emplace(
"components");
539 value.generateExcludedKeys();
544 void component_data::generateExcludedKeys() {
547 if (customId ==
"") {
548 excludedKeys.emplace(
"custom_id");
550 if (emoji.name ==
"") {
551 excludedKeys.emplace(
"emoji");
553 emoji.generateExcludedKeys();
556 excludedKeys.emplace(
"label");
558 if (placeholder ==
"") {
559 excludedKeys.emplace(
"placeholder");
562 excludedKeys.emplace(
"url");
564 excludedKeys.emplace(
"options");
565 excludedKeys.emplace(
"channel_types");
566 excludedKeys.emplace(
"placeholder");
567 excludedKeys.emplace(
"min_values");
568 excludedKeys.emplace(
"max_values");
569 excludedKeys.emplace(
"min_length");
570 excludedKeys.emplace(
"max_length");
571 excludedKeys.emplace(
"required");
572 excludedKeys.emplace(
"value");
573 excludedKeys.emplace(
"title");
577 if (customId ==
"") {
578 excludedKeys.emplace(
"custom_id");
581 excludedKeys.emplace(
"label");
583 if (maxLength == 0) {
584 excludedKeys.emplace(
"max_length");
586 if (minLength == 0) {
587 excludedKeys.emplace(
"min_length");
589 if (placeholder ==
"") {
590 excludedKeys.emplace(
"placeholder");
593 excludedKeys.emplace(
"title");
596 excludedKeys.emplace(
"value");
598 excludedKeys.emplace(
"style");
599 excludedKeys.emplace(
"label");
600 excludedKeys.emplace(
"emoji");
601 excludedKeys.emplace(
"url");
602 excludedKeys.emplace(
"min_length");
603 excludedKeys.emplace(
"max_length");
604 excludedKeys.emplace(
"required");
605 excludedKeys.emplace(
"title");
621 if (customId ==
"") {
622 excludedKeys.emplace(
"custom_id");
624 if (channelTypes.size() == 0) {
625 excludedKeys.emplace(
"channel_types");
628 excludedKeys.emplace(
"label");
630 if (maxValues == 0) {
631 excludedKeys.emplace(
"max_values");
633 if (minValues == 0) {
634 excludedKeys.emplace(
"min_values");
636 if (options.size() == 0) {
637 excludedKeys.emplace(
"options");
639 if (placeholder ==
"") {
640 excludedKeys.emplace(
"placeholder");
642 excludedKeys.emplace(
"style");
643 excludedKeys.emplace(
"label");
644 excludedKeys.emplace(
"emoji");
645 excludedKeys.emplace(
"url");
646 excludedKeys.emplace(
"min_length");
647 excludedKeys.emplace(
"max_length");
648 excludedKeys.emplace(
"required");
649 excludedKeys.emplace(
"value");
650 excludedKeys.emplace(
"title");
651 excludedKeys.emplace(
"placeholer");
657 void application_command_option_data::generateExcludedKeys() {
659 value.generateExcludedKeys();
662 value.generateExcludedKeys();
664 if (
maxValue == std::numeric_limits<int64_t>::min()) {
665 excludedKeys.emplace(
"max_value");
667 if (
minValue == std::numeric_limits<int64_t>::max()) {
668 excludedKeys.emplace(
"min_value");
671 excludedKeys.emplace(
"name_localizations");
674 excludedKeys.emplace(
"choices");
677 excludedKeys.emplace(
"options");
680 excludedKeys.emplace(
"autocomplete");
683 excludedKeys.emplace(
"description_localizations");
686 excludedKeys.emplace(
"channel_types");
690 void application_command_option_choice_data::generateExcludedKeys() {
692 excludedKeys.emplace(
"name_localizations");
696 void application_command_data::generateExcludedKeys() {
713 value.generateExcludedKeys();
721 return interactionData;
725 return interactionData.message;
731 returnData.components = components;
732 returnData.customId = customId;
733 returnData.choices = choices;
734 returnData.content = content;
735 returnData.embeds = embeds;
736 returnData.files = files;
737 returnData.flags = flags;
738 returnData.title = title;
739 returnData.tts = tts;
743 respond_to_input_event_data& respond_to_input_event_data::operator=(
const interaction_data dataPackage) {
744 applicationId = dataPackage.applicationId;
745 messageId = dataPackage.message.
id;
746 channelId = dataPackage.channelId;
747 interactionToken = dataPackage.token;
748 eventType = dataPackage.type;
749 interactionId = dataPackage.
id;
753 respond_to_input_event_data::respond_to_input_event_data(
const interaction_data dataPackage) {
757 respond_to_input_event_data& respond_to_input_event_data::operator=(
const input_event_data dataPackage) {
758 applicationId = dataPackage.getInteractionData().applicationId;
759 interactionToken = dataPackage.getInteractionData().token;
760 channelId = dataPackage.interactionData.channelId;
761 interactionId = dataPackage.getInteractionData().
id;
762 messageId = dataPackage.getMessageData().
id;
763 type = dataPackage.responseType;
767 respond_to_input_event_data::respond_to_input_event_data(
const input_event_data dataPackage) {
772 button_style buttonStyle, jsonifier::string_view emojiName,
snowflake emojiId, jsonifier::string_view url) {
773 if (components.size() == 0) {
775 components.emplace_back(actionRowData);
777 if (components.size() < 5) {
778 if (components[components.size() - 1].components.size() < 5) {
779 component_data component;
781 component.emoji.name = emojiName;
782 component.label = buttonLabel;
783 component.style =
static_cast<uint64_t
>(buttonStyle);
784 component.customId = customIdNew;
785 component.disabled = disabled;
786 component.emoji.id = emojiId;
788 components[components.size() - 1].components.emplace_back(component);
789 }
else if (components[components.size() - 1].components.size() == 5) {
791 components.emplace_back(actionRowData);
798 jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type typeNew, jsonifier::vector<channel_type> channelTypes) {
799 if (components.size() == 0) {
801 components.emplace_back(actionRowData);
803 if (components.size() < 5) {
804 if (components[components.size() - 1].components.size() < 5) {
805 component_data componentData;
807 componentData.channelTypes = channelTypes;
808 componentData.placeholder = placeholder;
809 componentData.customId = customIdNew;
810 componentData.maxValues = maxValues;
811 componentData.minValues = minValues;
812 componentData.disabled = disabled;
813 componentData.options = options;
814 components[components.size() - 1].components.emplace_back(componentData);
815 }
else if (components[components.size() - 1].components.size() == 5) {
817 components.emplace_back(actionRowData);
824 jsonifier::string_view customIdNew,
bool required, uint64_t minLength, uint64_t maxLength,
text_input_style inputStyle, jsonifier::string_view label,
825 jsonifier::string_view placeholder) {
827 customId = topCustomIdNew;
828 if (components.size() == 0) {
830 components.emplace_back(actionRowData);
832 if (components.size() < 5) {
833 if (components[components.size() - 1].components.size() < 5) {
834 component_data component{};
836 component.customId = customIdNew;
837 component.style =
static_cast<uint64_t
>(inputStyle);
838 component.title = titleNew;
839 component.maxLength = maxLength;
840 component.minLength = minLength;
841 component.label = label;
842 component.required = required;
843 component.placeholder = placeholder;
844 components[components.size() - 1].components.emplace_back(component);
845 }
else if (components[components.size() - 1].components.size() == 5) {
847 components.emplace_back(actionRowData);
854 files.emplace_back(theFile);
859 allowedMentions = dataPackage;
869 components.emplace_back(dataPackage);
874 embeds.emplace_back(dataPackage);
879 content = dataPackage;
889 unordered_map<jsonifier::string, jsonifier::string> theNameLocalizations) {
892 choiceData.name = theName;
893 choiceData.value = jsonifier::string{ value.operator jsonifier::string_base<uint8_t>() };
894 choices.emplace_back(choiceData);
899 targetUserId = targetUserIdNew;
904 jsonifier::string_view emojiName,
snowflake emojiId, jsonifier::string_view url) {
905 if (components.size() == 0) {
907 components.emplace_back(actionRowData);
909 if (components.size() < 5) {
910 if (components[components.size() - 1].components.size() < 5) {
911 component_data component;
913 component.emoji.name = emojiName;
914 component.label = buttonLabel;
915 component.style =
static_cast<uint64_t
>(buttonStyle);
916 component.customId = customIdNew;
917 component.disabled = disabled;
918 component.emoji.id = emojiId;
920 components[components.size() - 1].components.emplace_back(component);
921 }
else if (components[components.size() - 1].components.size() == 5) {
923 components.emplace_back(actionRowData);
930 jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type type, jsonifier::vector<channel_type> channelTypes) {
931 if (components.size() == 0) {
933 components.emplace_back(actionRowData);
935 if (components.size() < 5) {
936 if (components[components.size() - 1].components.size() < 5) {
937 component_data componentData;
939 componentData.channelTypes = channelTypes;
940 componentData.placeholder = placeholder;
941 componentData.customId = customIdNew;
942 componentData.maxValues = maxValues;
943 componentData.minValues = minValues;
944 componentData.disabled = disabled;
945 componentData.options = options;
946 components[components.size() - 1].components.emplace_back(componentData);
947 }
else if (components[components.size() - 1].components.size() == 5) {
949 components.emplace_back(actionRowData);
956 jsonifier::string_view customIdNew,
bool required, uint64_t minLength, uint64_t maxLength,
text_input_style inputStyle, jsonifier::string_view label,
957 jsonifier::string_view placeholder) {
959 customId = topCustomIdNew;
960 if (components.size() == 0) {
962 components.emplace_back(actionRowData);
964 if (components.size() < 5) {
965 if (components[components.size() - 1].components.size() < 5) {
966 component_data component{};
968 component.customId = customIdNew;
969 component.style =
static_cast<uint64_t
>(inputStyle);
970 component.title = titleNew;
971 component.maxLength = maxLength;
972 component.minLength = minLength;
973 component.label = label;
974 component.required = required;
975 component.placeholder = placeholder;
976 components[components.size() - 1].components.emplace_back(component);
977 }
else if (components[components.size() - 1].components.size() == 5) {
979 components.emplace_back(actionRowData);
986 files.emplace_back(theFile);
991 allowedMentions = dataPackage;
996 components.emplace_back(dataPackage);
1001 embeds.emplace_back(dataPackage);
1006 content = dataPackage;
1029 interaction_response_data::interaction_response_data(
const respond_to_input_event_data& other) {
1033 void parseCommandDataOption(unordered_map<jsonifier::string, json_string_value>& values, application_command_interaction_data_option& data) {
1034 json_string_value valueNew{};
1035 auto stringSize{ data.value.operator jsonifier::string_view().size() };
1036 if (stringSize > 1) {
1037 if (data.value.operator jsonifier::string_view().at(0) ==
'"' && data.value.operator jsonifier::string_view().at(stringSize - 1) ==
'"') {
1038 data.value =
static_cast<jsonifier::string
>(data.value.operator jsonifier::string_view().substr(1, data.value.operator jsonifier::string_view().size() - 2));
1041 valueNew.value = data.value;
1042 values[data.name] = valueNew;
1043 for (
auto& value: data.options) {
1044 parseCommandDataOption(values, value);
1053 subCommandGroupName = other.subCommandGroupName;
1054 subCommandName = other.subCommandName;
1055 commandName = other.commandName;
1056 optionsArgs = other.optionsArgs;
1057 eventData = other.eventData;
1061 command_data::command_data(
const command_data& other) {
1065 command_data::command_data(
const input_event_data& inputEventData) {
1066 if (inputEventData.interactionData.data.name !=
"") {
1067 commandName = inputEventData.interactionData.data.name;
1069 if (inputEventData.interactionData.data.targetId != 0) {
1070 optionsArgs.values.emplace(
"target_id",
1071 json_string_value{ .type = discord_core_internal::json_type::string_t, .value = inputEventData.interactionData.data.targetId.operator jsonifier::string() });
1072 }
else if (inputEventData.interactionData.data.targetId != 0) {
1073 optionsArgs.values.emplace(
"target_id",
1074 json_string_value{ .type = discord_core_internal::json_type::string_t, .value = inputEventData.interactionData.data.targetId.operator jsonifier::string() });
1076 eventData = inputEventData;
1077 for (
auto& value: eventData.interactionData.data.
options) {
1078 json_string_value serializer{ .value = value.value.operator jsonifier::string() };
1079 optionsArgs.values[value.name] = serializer;
1080 parseCommandDataOption(optionsArgs.values, value);
1082 for (
auto& value: eventData.interactionData.data.
options) {
1084 subCommandName = value.name;
1087 subCommandGroupName = value.name;
1093 return eventData.interactionData;
1117 return subCommandName;
1121 return subCommandGroupName;
1128 base_function_arguments::base_function_arguments(
const command_data& commanddataNew) :
command_data{ commanddataNew } {};
1130 move_through_message_pages_data moveThroughMessagePages(snowflake userID, input_event_data originalEvent, uint32_t currentPageIndex,
1131 const jsonifier::vector<embed_data>& messageEmbeds,
bool deleteAfter, uint32_t waitForMaxMs,
bool returnResult) {
1132 move_through_message_pages_data returnData{};
1133 uint32_t newCurrentPageIndex = currentPageIndex;
1134 stop_watch<milliseconds> stopWatch{ milliseconds{ waitForMaxMs } };
1136 auto createResponseData = makeUnique<create_interaction_response_data>(originalEvent);
1137 auto interactionResponse = makeUnique<respond_to_input_event_data>(originalEvent);
1138 auto embedData = makeUnique<embed_data>();
1139 embedData->setColor(
"FEFEFE");
1140 embedData->setTitle(
"__**Permissions Issue:**__");
1142 embedData->setDescription(
"Sorry, but that button can only be pressed by <@" + userID +
">!");
1143 createResponseData->addMessageEmbed(*embedData);
1145 if (messageEmbeds.size() > 0) {
1146 interactionResponse->addMessageEmbed(messageEmbeds[currentPageIndex]);
1149 interactionResponse->addButton(
false,
"select",
"Select",
button_style::Success, unicode_emojis::x);
1151 interactionResponse->addButton(
false,
"backwards",
"Prev Page",
button_style::Primary, unicode_emojis::arrow_left);
1152 interactionResponse->addButton(
false,
"forwards",
"Next Page",
button_style::Primary, unicode_emojis::arrow_right);
1153 interactionResponse->addButton(
false,
"exit",
"Exit",
button_style::Danger, unicode_emojis::x);
1156 while (!stopWatch.hasTimeElapsed()) {
1157 std::this_thread::sleep_for(1ms);
1158 unique_ptr<button_collector> button{ makeUnique<button_collector>(originalEvent) };
1159 jsonifier::vector<button_response_data> buttonIntData{ button->collectButtonData(
false, waitForMaxMs, 1, *createResponseData, userID).get() };
1160 unique_ptr<interaction_data> interactionData{ makeUnique<interaction_data>() };
1161 if (buttonIntData.size() == 0) {
1162 unique_ptr<respond_to_input_event_data> dataPackage02{ makeUnique<respond_to_input_event_data>(originalEvent) };
1164 dataPackage02->addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1165 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1166 action_row_data actionRow{};
1167 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1168 component_data component = originalEvent.getMessageData().components[x].components[y];
1169 component.disabled =
true;
1170 actionRow.components.emplace_back(component);
1172 dataPackage02->addButton(
false,
"backwards",
"Prev Page",
button_style::Primary, unicode_emojis::arrow_left);
1173 dataPackage02->addButton(
false,
"forwards",
"Next Page",
button_style::Primary, unicode_emojis::arrow_right);
1176 if (deleteAfter ==
true) {
1177 input_event_data dataPackage03{ originalEvent };
1183 move_through_message_pages_data dataPackage03{};
1184 dataPackage03.inputEventData = originalEvent;
1185 dataPackage03.buttonId =
"exit";
1186 return dataPackage03;
1188 }
else if (buttonIntData[0].buttonId ==
"empty" || buttonIntData[0].buttonId ==
"exit") {
1189 unique_ptr<respond_to_input_event_data> dataPackage02{ makeUnique<respond_to_input_event_data>(originalEvent) };
1190 if (buttonIntData[0].buttonId ==
"empty") {
1191 *dataPackage02 = originalEvent;
1193 interactionData = makeUnique<interaction_data>(buttonIntData[0]);
1194 *dataPackage02 = respond_to_input_event_data{ *interactionData };
1197 dataPackage02->addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1198 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1199 action_row_data actionRow{};
1200 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1201 component_data component = originalEvent.getMessageData().components[x].components[y];
1202 component.disabled =
true;
1203 actionRow.components.emplace_back(component);
1205 dataPackage02->addButton(
false,
"backwards",
"Prev Page",
button_style::Primary, unicode_emojis::arrow_left);
1206 dataPackage02->addButton(
false,
"forwards",
"Next Page",
button_style::Primary, unicode_emojis::arrow_right);
1209 if (deleteAfter ==
true) {
1210 input_event_data dataPackage03{ originalEvent };
1216 move_through_message_pages_data dataPackage03{};
1217 dataPackage03.inputEventData = originalEvent;
1218 dataPackage03.buttonId =
"exit";
1219 return dataPackage03;
1220 }
else if (buttonIntData[0].buttonId ==
"forwards" || buttonIntData[0].buttonId ==
"backwards") {
1221 if (buttonIntData[0].buttonId ==
"forwards" && (newCurrentPageIndex == (messageEmbeds.size() - 1))) {
1222 newCurrentPageIndex = 0;
1223 }
else if (buttonIntData[0].buttonId ==
"forwards" && (newCurrentPageIndex < messageEmbeds.size())) {
1224 ++newCurrentPageIndex;
1225 }
else if (buttonIntData[0].buttonId ==
"backwards" && (newCurrentPageIndex > 0)) {
1226 --newCurrentPageIndex;
1227 }
else if (buttonIntData[0].buttonId ==
"backwards" && (newCurrentPageIndex == 0)) {
1228 newCurrentPageIndex =
static_cast<uint32_t
>(messageEmbeds.size()) - 1;
1230 interactionData = makeUnique<interaction_data>(buttonIntData[0]);
1231 auto dataPackage = respond_to_input_event_data{ *interactionData };
1233 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1234 action_row_data actionRow{};
1235 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1236 component_data component = originalEvent.getMessageData().components[x].components[y];
1237 component.disabled =
false;
1238 actionRow.components.emplace_back(component);
1240 dataPackage.addButton(
false,
"backwards",
"Prev Page",
button_style::Primary, unicode_emojis::arrow_left);
1241 dataPackage.addButton(
false,
"forwards",
"Next Page",
button_style::Primary, unicode_emojis::arrow_right);
1244 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1246 }
else if (buttonIntData[0].buttonId ==
"select") {
1247 if (deleteAfter ==
true) {
1248 input_event_data dataPackage03{ originalEvent };
1251 unique_ptr<interaction_data> interactionDataNew = makeUnique<interaction_data>(buttonIntData[0]);
1252 auto dataPackage = respond_to_input_event_data{ *interactionDataNew };
1254 dataPackage.addMessageEmbed(messageEmbeds[newCurrentPageIndex]);
1255 for (uint64_t x = 0; x < originalEvent.getMessageData().components.size(); ++x) {
1256 action_row_data actionRow{};
1257 for (uint64_t y = 0; y < originalEvent.getMessageData().components[x].components.size(); ++y) {
1258 component_data component = originalEvent.getMessageData().components[x].components[y];
1259 component.disabled =
true;
1260 actionRow.components.emplace_back(component);
1262 dataPackage.addComponentRow(actionRow);
1266 returnData.currentPageIndex = newCurrentPageIndex;
1267 returnData.inputEventData = originalEvent;
1268 returnData.buttonId = buttonIntData[0].buttonId;
Action row data of message components.
jsonifier::vector< component_data > components
Array of components to make up the action-row.
Allowable mentions for a message.
jsonifier::vector< jsonifier::string > roles
Array of role_ids to mention (max size of 100)
jsonifier::vector< jsonifier::string > users
Array of user_ids to mention (max size of 100)
jsonifier::vector< jsonifier::string > parse
A vector of allowed mention types to parse from the content.
jsonifier::vector< application_command_option_data > options
A vector of possible options for the current application_command_data.
unordered_map< jsonifier::string, jsonifier::string > descriptionLocalizations
Dictionary with keys in available locales.
application_command_type type
The type of application_command_data.
unordered_set< jsonifier::string > excludedKeys
Keys to exclude at serialization time.
snowflake guildId
(where applicable) a guild id for which guild to assign this application_command_data to.
jsonifier::string description
A description of the current application_command_data.
jsonifier::string version
An autoincremented version.
unordered_map< jsonifier::string, jsonifier::string > nameLocalizations
Dictionary with keys in available locales.
jsonifier::string name
Name of the current application_command_data.
Data structure representing an application_command_data's option choice.
jsonifier::string name
The name of the current choice.
unordered_map< jsonifier::string, jsonifier::string > nameLocalizations
Dictionary with keys in available locales localization dictionary for the name.
jsonifier::raw_json_data value
The value of the option.
jsonifier::vector< audit_log_entry_data > auditLogEntries
Array of audit log entry objects.
void updateVoiceStatus(update_voice_state_data dataPackage)
Updates the bot's current voice-status. joins/leaves a channel, and/or self deafens/mutes.
Command data, for functions executed by the command_controller.
const guild_member_data & getGuildMemberData() const
Returns the guild_member_data of this input-event.
jsonifier::string getSubCommandName() const
Returns the subcommand-name of this entered command.
const input_event_data & getInputEventData() const
Returns the input_event_data for this command.
const user_data & getUserData() const
Returns the user_data of this input-event.
const interaction_data & getInteractionData() const
Returns the interaction data, if appplicable, of this input-event.
jsonifier::string getCommandName() const
Returns the name of this entered command.
const channel_data & getChannelData() const
Returns the channel_data of this input-event.
jsonifier::string getSubCommandGroupName() const
Returns the subcommand-name of this entered command group.
const message_data & getMessageData() const
Returns the message data, if applicable, of this input-event.
serializer_value getCommandArguments() const
Returns the collection of command inputs/options for this command.
static bot_user getBotUser()
For collecting a copy of the current bot's user_data.
jsonifier::string description
Description of the embed.
jsonifier::string title
Title of the embed.
embed_data & setImage(jsonifier::string_view imageUrl)
Sets the image of the embed.
embed_provider_data provider
Embed provider data.
embed_data & setTimeStamp(jsonifier::string_view timeStamp)
Sets the timeStamp on the embed.
embed_image_data image
Embed image data.
jsonifier::string type
Type of the embed.
uint64_t hexColorValue
Hex color value of the embed.
unordered_set< jsonifier::string > excludedKeys
For excluding certain keys from parsing/serialization.
embed_data & addField(jsonifier::string_view name, jsonifier::string_view value, bool Inline=true)
Adds a field to the embed.
embed_thumbnail_data thumbnail
Embed thumbnail data.
embed_data & setFooter(jsonifier::string_view footerText, jsonifier::string_view footerIconUrlText="")
Sets the footer's values for the embed.
jsonifier::string url
Url for the embed.
embed_data & setAuthor(jsonifier::string_view authorName, jsonifier::string_view authorAvatarUrl="")
Sets the author's name and avatar for the embed.
embed_footer_data footer
Embed footer data.
embed_data & setColor(jsonifier::string_view hexColorValueNew)
Sets the color of the embed, by applying a hex-color value.
jsonifier::vector< embed_field_data > fields
Array of embed fields.
embed_video_data video
Embed video data.
time_stamp timeStamp
Timestamp to be placed on the embed.
embed_author_data author
Embed author data.
embed_data & setTitle(jsonifier::string_view titleNew)
Sets the title of the embed.
embed_data & setDescription(jsonifier::string_view descriptionNew)
Sets the description (the main contents) of the embed.
embed_data & setThumbnail(jsonifier::string_view thumbnailUrl)
Sets the thumbnail of the embed.
unordered_set< jsonifier::string > excludedKeys
Excluding keys from parsing/serializing.
bool managed
Is it managed?
std::wstring unicodeName
What is its unicode name?
jsonifier::vector< role_data > roles
Roles that are allowed to use this emoji.
void disconnect()
For disconnecting from the current guild's voice channel.
snowflake id
The id of this guild.
void disconnect()
For disconnecting from the current guild's voice channel.
user_id_base user
The user id for this guild_member_data.
Data structure representing a single guild_member_data.
snowflake guildId
The guild that this member belongs to.
user_data user
The user this guild member represents.
static voice_state_data_light getVoiceStateData(const two_id_key &voiceState)
Collect a given guild_member's voice state data.
Data structure representing a single message_data.
Message response base, for responding to messages.
message_response_base & addButton(bool disabled, jsonifier::string_view customIdNew, jsonifier::string_view buttonLabel, button_style buttonStyle, jsonifier::string_view emojiName="", snowflake emojiId=snowflake{}, jsonifier::string_view url="")
Adds a button to the response message_data.
message_response_base & addSelectMenu(bool disabled, jsonifier::string_view customIdNew, jsonifier::vector< select_option_data > options, jsonifier::string_view placeholder, uint64_t maxValues, uint64_t minValues, select_menu_type type, jsonifier::vector< channel_type > channelTypes=jsonifier::vector< channel_type >{})
Adds a select-menu to the response message_data.
message_response_base & setTTSStatus(bool enabledTTs)
For setting the tts status of a response.
message_response_base & addModal(jsonifier::string_view topTitleNew, jsonifier::string_view topCustomIdNew, jsonifier::string_view titleNew, jsonifier::string_view customIdNew, bool required, uint64_t minLength, uint64_t maxLength, text_input_style inputStyle, jsonifier::string_view label="", jsonifier::string_view placeholder="")
Adds a modal to the response message_data.
message_response_base & addMessageEmbed(const embed_data dataPackage)
For setting the embeds in a response.
message_response_base & addContent(jsonifier::string_view dataPackage)
For setting the message content in a response.
message_response_base & addAllowedMentions(const allowed_mentions_data dataPackage)
For setting the allowable mentions in a response.
message_response_base & addFile(file theFile)
Adds a file to the current collection of files for this message response.
message_response_base & addComponentRow(const action_row_data dataPackage)
For setting the components in a response.
unordered_set< jsonifier::string > excludedKeys
Excluding keys from parsing/serializing.
jsonifier::string name
What is its name?
A class representing a snowflake identifier with various operations.
uint64_t id
The snowflake id.
snowflake id
The user's id.
static user_cache_data getCachedUser(const get_user_data dataPackage)
Collects a given user from the library's cache.
input_event_response_type
Input event response types.
button_style
Button styles.
audit_log_event
Audit log events.
text_input_style
Text input style for modals.
component_type
Component types.
DiscordCoreAPI_Dll jsonifier::string getTimeAndDate()
Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
@ Edit_Interaction_Response
Interaction response edit.
@ Channel_Message_With_Source
Respond to an interaction with a message.
@ Action_Row
container for other components.
@ Role_Select
Select menu for roles.
@ Mentionable_Select
Select menu for mentionables (users and roles).
@ Channel_Select
Select menu for channels.
@ String_Select
Select menu for picking from defined text options.
@ User_Select
Select menu for users.
@ Text_Input
Text input object.
@ Sub_Command
Sub-command.
@ Sub_Command_Group
Sub-command group.
The main namespace for the forward-facing interfaces.
Data structure representing an application_command_data's option.
int64_t minValue
If the option is an integer or number type, the minimum value permitted.
bool autocomplete
If autocomplete interactions are enabled for this string, integer, or number type option.
jsonifier::string description
A description of the current application_command_data option.
jsonifier::vector< channel_type > channelTypes
Set when the application_command_data option type is set to channel_data.
bool required
If the parameter is required or optional– default false.
jsonifier::vector< application_command_option_choice_data > choices
A vector of possible choices for the current application_command_data option.
jsonifier::vector< application_command_option_data > options
A vector of possible options for the current application_command_data option.
jsonifier::string name
Name of the current application_command_data option.
application_command_option_type type
The type of command option.
unordered_map< jsonifier::string, jsonifier::string > nameLocalizations
Dictionary for the name localizations field.
int64_t maxValue
If the option is an integer or number type, the maximum value permitted.
unordered_map< jsonifier::string, jsonifier::string > descriptionLocalizations
Dictionary for the description localizations field.
jsonifier::string iconUrl
Icon url.
jsonifier::string name
Name.
unordered_set< jsonifier::string > excludedKeys
For excluding certain keys from parsing/serialization.
jsonifier::string url
Url.
jsonifier::string proxyIconUrl
Proxy icon url.
bool Inline
Is the field inline with the rest of them?
uint64_t height
Image height.
jsonifier::string url
Image url.
unordered_set< jsonifier::string > excludedKeys
For excluding certain keys from parsing/serialization.
jsonifier::string proxyUrl
Proxy url.
uint64_t width
Image width.
jsonifier::string url
Url.
jsonifier::string name
Name.
uint64_t height
Image height.
jsonifier::string url
Image url.
jsonifier::string proxyUrl
Proxy url.
uint64_t width
Image width.
jsonifier::string proxyUrl
Proxy url.
uint64_t width
Image width.
jsonifier::string url
Image url.
uint64_t height
Image height.
Data representing a file to be sent via multipart-form data.
Interaction application_command_data callback data.
jsonifier::vector< action_row_data > components
Message components.
jsonifier::string title
The title of the popup modal.
jsonifier::vector< file > files
Files for uploading.
jsonifier::vector< attachment_data > attachments
Array of partial attachment objects attachment objects with filename and description.
jsonifier::string customId
A developer-defined identifier for the component, max 100 characters.
allowed_mentions_data allowedMentions
Allowed mentions data.
jsonifier::string content
Message content.
unordered_set< jsonifier::string > excludedKeys
Keys to exclude from parsing/serializing.
jsonifier::vector< application_command_option_choice_data > choices
Autocomplete choices(max of 25 choices).
jsonifier::vector< embed_data > embeds
Message embeds.
jsonifier::vector< application_command_interaction_data_option > options
Application_command_data interaction data options.
Interaction response data.
interaction_callback_data data
Interaction application_command_data callback data.
For updating the current voice state.
snowflake channelId
snowflake of the desired voice channel_data. leave blank to disconnect.