From a6d102265e6f3381766e369dd643c9c728c2a1f7 Mon Sep 17 00:00:00 2001 From: RealTimeChris <40668522+RealTimeChris@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:42:37 -0400 Subject: [PATCH] DiscordCoreAPI Release v2.0.8 --- .github/workflows/MSVC-Windows-Binaries.yml | 72 ++ .github/workflows/MSVC-Windows.yml | 3 +- CMake/DCADetectArchitecture.cmake | 17 +- Documentation/Doxygen/Docs/Index.md | 18 +- .../documentation_examples/music_bot/PlayQ.md | 2 +- Include/discordcoreapi/FoundationEntities.hpp | 34 +- .../discordcoreapi/JsonSpecializations.hpp | 32 +- Include/discordcoreapi/Utilities.hpp | 45 +- Include/discordcoreapi/Utilities/Etf.hpp | 410 +++------ .../discordcoreapi/Utilities/RingBuffer.hpp | 30 +- .../Utilities/UnboundedMessageBlock.hpp | 4 +- .../discordcoreapi/Utilities/UnorderedSet.hpp | 4 +- .../Utilities/WebSocketClient.hpp | 4 +- Library/CMake/BuildFeatureTester.bat | 2 - ReadMe.md | 16 +- Source/EventManager.cpp | 120 +-- Source/FoundationEntities.cpp | 8 +- Source/SoundCloudAPI.cpp | 83 +- Source/VoiceConnection.cpp | 12 +- Source/WebSocketClient.cpp | 788 +++++++++--------- Source/YouTubeAPI.cpp | 4 +- Vcpkg/ports/discordcoreapi/portfile.cmake | 3 +- Vcpkg/ports/discordcoreapi/vcpkg.json | 2 +- Vcpkg/versions/d-/discordcoreapi.json | 25 + 24 files changed, 864 insertions(+), 874 deletions(-) create mode 100644 .github/workflows/MSVC-Windows-Binaries.yml delete mode 100644 Library/CMake/BuildFeatureTester.bat diff --git a/.github/workflows/MSVC-Windows-Binaries.yml b/.github/workflows/MSVC-Windows-Binaries.yml new file mode 100644 index 000000000..8fc7e3b03 --- /dev/null +++ b/.github/workflows/MSVC-Windows-Binaries.yml @@ -0,0 +1,72 @@ +name: Build-and-Test-MSVC-Windows + +on: + workflow_dispatch: + push: + branches: + - main + - dev + +jobs: + Build: + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + msvc: [2022] + build_type: [Debug, Release] + std: [20] + + steps: + - uses: actions/checkout@v4 + + - name: Update Vcpkg and install other dependencies + run: | + cd C:/vcpkg + ./bootstrap-vcpkg.bat + git stash + git pull + vcpkg update + + - name: Install the dependencies + run: | + vcpkg install opus:x64-windows + vcpkg install libsodium:x64-windows + vcpkg install openssl:x64-windows + + - name: Configure CMake + working-directory: ./ + run: | + cmake -S . -B ./Build -DDEV=true -DVCPKG_ROOT_DIR=C:/vcpkg + + - name: Build the Test + working-directory: ./Build + run: | + cmake --build . --config=${{matrix.build_type}} + + - name: Install the Test + working-directory: ./Build/ + run: | + cmake --install ./ --config=${{matrix.build_type}} + + - name: Clone DiscordCoreAPI-Binaries repository + run: | + git clone https://github.com/RealTimeChris/DiscordCoreAPI-Binaries.git ./DiscordCoreAPI-Binaries + cd DiscordCoreAPI-Binaries + git config user.name "GitHub Action" + git config user.email "action@github.com" + + - name: Copy build artifacts to DiscordCoreAPI-Binaries + run: | + cp -r -Force "C:/Program Files (x86)/DiscordCoreAPI/*" ./DiscordCoreAPI-Binaries/${{matrix.build_type}} -v + cd ./DiscordCoreAPI-Binaries/${{matrix.build_type}} + Remove-Item -Force ./bin/discordcoreapi.pdb + + - name: Commit and push changes to DiscordCoreAPI-Binaries + working-directory: ./DiscordCoreAPI-Binaries + run: | + git add . + git commit -m "Update binaries for ${{matrix.build_type}} build" + git push https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/RealTimeChris/DiscordCoreAPI-Binaries.git main + continue-on-error: true diff --git a/.github/workflows/MSVC-Windows.yml b/.github/workflows/MSVC-Windows.yml index 3790ab3ea..961bb1667 100644 --- a/.github/workflows/MSVC-Windows.yml +++ b/.github/workflows/MSVC-Windows.yml @@ -65,7 +65,6 @@ jobs: - name: Copy build artifacts to DiscordCoreAPI-Binaries run: | - mkdir -p ./DiscordCoreAPI-Binaries/${{matrix.build_type}} cp -r ./Tests/Install/${{matrix.build_type}}/* ./DiscordCoreAPI-Binaries/${{matrix.build_type}} - name: Commit and push changes to DiscordCoreAPI-Binaries @@ -73,5 +72,5 @@ jobs: run: | git add . git commit -m "Update binaries for ${{matrix.build_type}} build" - git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/RealTimeChris/DiscordCoreAPI-Binaries.git main + git push https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/RealTimeChris/DiscordCoreAPI-Binaries.git main continue-on-error: true diff --git a/CMake/DCADetectArchitecture.cmake b/CMake/DCADetectArchitecture.cmake index 5edd8a3fa..f4b44e5ff 100644 --- a/CMake/DCADetectArchitecture.cmake +++ b/CMake/DCADetectArchitecture.cmake @@ -34,8 +34,19 @@ execute_process( RESULT_VARIABLE DCA_CPU_INSTRUCTIONS_NEW ) -set(AVX_FLAG "") +function(is_numeric value result_var) + string(REGEX MATCH "^[0-9]+(\\.[0-9]+)?$" is_numeric_match "${value}") + if(is_numeric_match) + set(${result_var} TRUE PARENT_SCOPE) + else() + set(${result_var} FALSE PARENT_SCOPE) + endif() +endfunction() + +is_numeric("${DCA_CPU_INSTRUCTIONS_NEW}" is_numeric_result) +set(AVX_FLAG "") +if (is_numeric_result) math(EXPR DCA_CPU_INSTRUCTIONS_NUMERIC "${DCA_CPU_INSTRUCTIONS_NEW}") math(EXPR DCA_CPU_INSTRUCTIONS 0) @@ -99,6 +110,8 @@ else() check_instruction_set("Avx2" "-mavx2;-mavx;-mlzcnt;-mpopcnt;-mbmi;-mbmi2" 0x40) check_instruction_set("Avx512" "-mavx512f;-mavx2;-mavx;-mlzcnt;-mpopcnt;-mbmi;-mbmi2" 0x80) endif() - +else() +set(DCA_CPU_INSTRUCTIONS "0") +endif() set(AVX_FLAG "${AVX_FLAG}" CACHE STRING "AVX flags" FORCE) set(DCA_CPU_INSTRUCTIONS "${DCA_CPU_INSTRUCTIONS}" CACHE STRING "CPU Instruction Sets" FORCE) diff --git a/Documentation/Doxygen/Docs/Index.md b/Documentation/Doxygen/Docs/Index.md index aa5ed0c5f..ca840302c 100644 --- a/Documentation/Doxygen/Docs/Index.md +++ b/Documentation/Doxygen/Docs/Index.md @@ -1,8 +1,8 @@ \mainpage DiscordCoreAPI [![Codacy Badge](https://img.shields.io/codacy/grade/1e5ae970aed34d0b96249cdfd02099cf?color=lightblue&label=Code%20Quality&style=plastic)](https://www.codacy.com/gh/RealTimeChris/DiscordCoreAPI/dashboard?utm_source=github.com&utm_medium=referral&utm_content=RealTimeChris/DiscordCoreAPI&utm_campaign=Badge_Grade) -[![Discord](https://img.shields.io/discord/931640556814237706?color=red&label=Discord%20Server&style=plastic)](https://discord.gg/adgMqeBuhP) +[![Discord](https://img.shields.io/discord/931640556814237706?color=red&label=Discord%20Server&style=plastic)](https://discord.gg/c33GH5BUe8) ![Commit Activity](https://img.shields.io/github/commit-activity/y/realtimechris/discordcoreapi?color=green&label=Commits&style=plastic) -![Lines of Code](https://tokei.rs/b1/github/RealTimeChris/DiscordCoreAPI?color=light-blue&label=Lines%20Of%20Code%20&style=plastic) +![Lines of Code](https://tokei.rs/b1/github/RealTimeChris/DiscordCoreAPI-Code-Only?color=light-blue&label=Lines%20Of%20Code%20&style=plastic) Hello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in C++, that leverages custom asynchronous \ref discord_core_api::co_routine "CoRoutines", as well as a home-brew set of \ref discord_core_api::discord_core_internal::https_client "Https", \ref discord_core_api::discord_core_internal::websocket_client "WebSocket", and \ref discord_core_api::voice_connection "Datagram" socket clients - all to deliver the utmost performance and efficiency for your bot. It uses roughly 0.1% of an Intel i7 9750h CPU to stream audio in high quality (Opus @ 48Khz, 16-bit) to a single server. @@ -10,20 +10,20 @@ Hello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in ![imageDiscordCoreAPI](./TheLogo.png "A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.") ## Compiler Support -![MSVC_20922](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC_2022-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=MSVC_2022&labelColor=pewter&color=blue) -![CLANG_18](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG_18-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=CLANG_18&labelColor=pewter&color=blue) -![GCC_13](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC_13-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=GCC_13&labelColor=pewter&color=blue) +![MSVC_20922](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=MSVC_2022&labelColor=pewter&color=blue) +![CLANG_18](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=CLANG_18&labelColor=pewter&color=blue) +![GCC_13](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=GCC_13&labelColor=pewter&color=blue) ## Operating System Support -![Windows](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC_2022-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=Windows&labelColor=pewter&color=blue) -![Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG_18-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=Linux&labelColor=pewter&color=blue) -![Mac](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC_13-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=MacOS&labelColor=pewter&color=blue) +![Windows](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=Windows&labelColor=pewter&color=blue) +![Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=Linux&labelColor=pewter&color=blue) +![Mac](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=MacOS&labelColor=pewter&color=blue) # Documentation/Examples \ref documentation_examples # Discord Server -[This is a link to the Discord server!](https://discord.gg/adgMqeBuhP) +[This is a link to the Discord server!](https://discord.gg/c33GH5BUe8) # Bot Template [A template for utilizing this library.](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI) diff --git a/Documentation/Doxygen/Docs/documentation_examples/music_bot/PlayQ.md b/Documentation/Doxygen/Docs/documentation_examples/music_bot/PlayQ.md index a1e31462e..b1c4dc562 100644 --- a/Documentation/Doxygen/Docs/documentation_examples/music_bot/PlayQ.md +++ b/Documentation/Doxygen/Docs/documentation_examples/music_bot/PlayQ.md @@ -162,7 +162,7 @@ namespace discord_core_api { if (trackNumber >= song_api::getPlaylist(guild_data.id).songQueue.size()) { unique_ptr newEmbed{ makeUnique() }; newEmbed->setAuthor(newEvent.getUserName(), newEvent.getAvatarUrl()); - newEmbed->setDescription("------\n__**sorry, but that number is out of the range of the current track list!**__\n------"); + newEmbed->setDescription("------\n__**sorry, but that number is out of the has_range of the current track list!**__\n------"); newEmbed->setTimeStamp(getTimeAndDate()); newEmbed->setTitle("__**playing issue:**__"); newEmbed->setColor(discordGuild.data.borderColor); diff --git a/Include/discordcoreapi/FoundationEntities.hpp b/Include/discordcoreapi/FoundationEntities.hpp index ce54f4108..0f4304785 100644 --- a/Include/discordcoreapi/FoundationEntities.hpp +++ b/Include/discordcoreapi/FoundationEntities.hpp @@ -30,6 +30,7 @@ #pragma once #include +#include namespace discord_core_api { @@ -321,23 +322,27 @@ namespace discord_core_api { }; struct websocket_message { - jsonifier::string t{}; + std::optional t{}; + std::optional s{}; int64_t op{ -1 }; - int64_t s{}; }; template struct websocket_message_data { unordered_set jsonifierExcludedKeys{}; - jsonifier::string t{}; + std::optional t{}; + std::optional s{}; value_type d{}; int64_t op{}; - int64_t s{}; DCA_INLINE operator discord_core_internal::etf_serializer() { etf_serializer data{}; data["op"] = op; - data["s"] = s; - data["t"] = t; + if (s.has_value()) { + data["s"] = s.value(); + } + if (t.has_value()) { + data["t"] = t.value(); + } data["d"] = d.operator discord_core_internal::etf_serializer(); return data; } @@ -407,18 +412,20 @@ namespace discord_core_api { template class flag_entity { public: - template DCA_INLINE auto setFlagValue(value_type02 theFlagToSet, bool enabled) { - auto newValue = static_cast(static_cast(this)->flags); + template DCA_INLINE void setFlagValue(flag_type theFlagToSet, bool enabled) { + using underlying_type = std::underlying_type_t; + auto newValue = static_cast(static_cast(this)->flags); if (enabled) { - newValue |= static_cast(theFlagToSet); + newValue |= static_cast(theFlagToSet); } else { - newValue &= ~static_cast(theFlagToSet); + newValue &= ~static_cast(theFlagToSet); } - static_cast(this)->flags = static_cast(newValue); + static_cast(this)->flags = static_cast(newValue); } - template DCA_INLINE bool getFlagValue(value_type02 theFlagToCheckFor) const { - return static_cast(static_cast(this)->flags) & static_cast(theFlagToCheckFor); + template DCA_INLINE bool getFlagValue(flag_type theFlagToCheckFor) const { + using underlying_type = std::underlying_type_t; + return static_cast(static_cast(this)->flags) & static_cast(theFlagToCheckFor); } protected: @@ -426,6 +433,7 @@ namespace discord_core_api { DCA_INLINE ~flag_entity() = default; }; + enum class user_image_types { Banner = 0, Default_Avatar = 1, diff --git a/Include/discordcoreapi/JsonSpecializations.hpp b/Include/discordcoreapi/JsonSpecializations.hpp index d68bb5950..bac3ebcd8 100644 --- a/Include/discordcoreapi/JsonSpecializations.hpp +++ b/Include/discordcoreapi/JsonSpecializations.hpp @@ -41,8 +41,8 @@ namespace discord_core_api { websocket_message_data(const update_voice_state_data& data); unordered_set jsonifierExcludedKeys{}; using type = update_voice_state_data; + std::optional t{}; int64_t op{ -1 }; - jsonifier::string t{}; int32_t s{}; type d{}; operator etf_serializer(); @@ -53,8 +53,8 @@ namespace discord_core_api { websocket_message_data(const update_voice_state_data& data); unordered_set jsonifierExcludedKeys{}; using type = update_voice_state_data_dc; + std::optional t{}; int64_t op{ -1 }; - jsonifier::string t{}; int32_t s{}; type d{}; operator etf_serializer(); @@ -65,13 +65,13 @@ namespace discord_core_api { namespace jsonifier_internal { template - concept snowflake_t = std::same_as>; + concept snowflake_t = std::same_as>; - template - struct serialize_impl { - template JSONIFIER_ALWAYS_INLINE static void impl(value_type_new&& value, buffer_type& buffer, serialize_context_type& serializePair) noexcept { + template + struct serialize_impl { + template JSONIFIER_ALWAYS_INLINE static void impl(value_type_new&& value, buffer_type& buffer, index_type&index, indent_type& indent) noexcept { jsonifier::string newString{ static_cast(value) }; - serialize::impl(newString, buffer, serializePair); + serialize::impl(newString, buffer, index, indent); } }; @@ -80,21 +80,21 @@ namespace jsonifier_internal { jsonifier::raw_json_data newString{}; parse::impl(newString, context); if (newString.getType() == jsonifier::json_type::String) { - value = newString.operator jsonifier::string(); + value = newString.get(); } else { - value = newString.operator uint64_t(); + value = newString.get(); } } }; template - concept time_stamp_t = std::same_as>; + concept time_stamp_t = std::same_as>; - template - struct serialize_impl { - template JSONIFIER_ALWAYS_INLINE static void impl(value_type_new&& value, buffer_type& buffer, serialize_context_type& serializePair) noexcept { + template + struct serialize_impl { + template JSONIFIER_ALWAYS_INLINE static void impl(value_type_new&& value, buffer_type& buffer, index_type& index, indent_type& indent) noexcept { jsonifier::string newString{ static_cast(value) }; - serialize::impl(newString, buffer, serializePair); + serialize::impl(newString, buffer, index, indent); } }; @@ -104,9 +104,9 @@ namespace jsonifier_internal { jsonifier::raw_json_data newString{}; parse::impl(newString, context); if (newString.getType() == jsonifier::json_type::String) { - value = newString.operator jsonifier::string(); + value = newString.get(); } else { - value = newString.operator uint64_t(); + value = newString.get(); } } }; diff --git a/Include/discordcoreapi/Utilities.hpp b/Include/discordcoreapi/Utilities.hpp index f969e0a9d..b86a52a9a 100644 --- a/Include/discordcoreapi/Utilities.hpp +++ b/Include/discordcoreapi/Utilities.hpp @@ -164,27 +164,29 @@ namespace discord_core_api { /// @brief Gateway intents. enum class gateway_intents : uint32_t { - guilds = 1 << 0,///< Intent for receipt of guild information. - Guild_Members = 1 << 1,///< Intent for receipt of guild members. - Guild_Bans = 1 << 2,///< Intent for receipt of guild bans. - Guild_Emojis = 1 << 3,///< Intent for receipt of guild emojis. - Guild_Integrations = 1 << 4,///< Intent for receipt of guild integrations. - Guild_Webhooks = 1 << 5,///< Intent for receipt of guild webhooks. - Guild_Invites = 1 << 6,///< Intent for receipt of guild invites. - Guild_VoiceStates = 1 << 7,///< Intent for receipt of guild voice states. - Guild_Presences = 1 << 8,///< Intent for receipt of guild presences. - Guild_Messages = 1 << 9,///< Intent for receipt of guild messages. - Guild_Message_Reactions = 1 << 10,///< Intent for receipt of guild message reactions. - Guild_Message_Typing = 1 << 11,///< Intent for receipt of guild message typing notifications. - Direct_Messages = 1 << 12,///< Intent for receipt of direct messages (dms). - Direct_Message_Reactions = 1 << 13,///< Intent for receipt of direct message reactions. - Direct_Message_Typing = 1 << 14,///< Intent for receipt of direct message typing notifications. - Message_Content = 1 << 15,///< Intent for receipt of message content. - Guild_Scheduled_Events = 1 << 16,///< Scheduled events. - Auto_Moderation_Configuration = 1 << 20,/// auto moderation configuration. - Auto_Moderation_Execution = 1 << 21,///< Auto moderation execution. - Default_Intents = guilds | Guild_Bans | Guild_Emojis | Guild_Integrations | Guild_Webhooks | Guild_Invites | Guild_VoiceStates | Guild_Messages | Guild_Message_Reactions | - Guild_Message_Typing | Direct_Messages | Direct_Message_Reactions | Direct_Message_Typing | Guild_Scheduled_Events | Auto_Moderation_Configuration | + Guilds = 1 << 0, + Guild_Members = 1 << 1, + Guild_Moderation = 1 << 2, + Guild_Expressions = 1 << 3, + Guild_Integrations = 1 << 4, + Guild_Webhooks = 1 << 5, + Guild_Invites = 1 << 6, + Guild_Voice_States = 1 << 7, + Guild_Presences = 1 << 8, + Guild_Messages = 1 << 9, + Guild_Message_Reactions = 1 << 10, + Guild_Message_Typing = 1 << 11, + Direct_Messages = 1 << 12, + Direct_Message_Reactions = 1 << 13, + Direct_Message_Typing = 1 << 14, + Message_Content = 1 << 15, + Guild_Scheduled_Events = 1 << 16, + Auto_Moderation_Configuration = 1 << 20, + Auto_Moderation_Execution = 1 << 21, + Guild_Message_Polls = 1 << 24, + Direct_Message_Polls = 1 << 25,///< Auto moderation execution. + Default_Intents = Guilds | Guild_Integrations | Guild_Webhooks | Guild_Invites | Guild_Voice_States | Guild_Messages | Guild_Message_Reactions | Guild_Message_Typing | + Direct_Messages | Direct_Message_Reactions | Direct_Message_Typing | Guild_Scheduled_Events | Auto_Moderation_Configuration | Auto_Moderation_Execution,///< Default intents (all non-privileged intents). Privileged_Intents = Guild_Members | Guild_Presences | Message_Content,///< Privileged intents requiring id. All_Intents = Default_Intents | Privileged_Intents///< Every single intent. @@ -534,7 +536,6 @@ namespace discord_core_api { /// @brief Permissions_base class, for representing and manipulating permission values. template class permissions_base { public: - /// @brief Returns a string containing all of a given user's permissions_base for a given channel. /// @param guildMember the guild_member_data who's permissions_base to analyze. /// @param channel the channel_data withint which to check for permissions_base. diff --git a/Include/discordcoreapi/Utilities/Etf.hpp b/Include/discordcoreapi/Utilities/Etf.hpp index 6540805e1..b723d1be5 100644 --- a/Include/discordcoreapi/Utilities/Etf.hpp +++ b/Include/discordcoreapi/Utilities/Etf.hpp @@ -446,7 +446,8 @@ namespace discord_core_api { /// @brief Constructor for etf_serialize_error. /// @param message the error message. /// @param location source location where the error occurred. - DCA_INLINE etf_serialize_error(const jsonifier::string_view& message, std::source_location location = std::source_location::current()) : dca_exception{ message, location } {}; + DCA_INLINE etf_serialize_error(const jsonifier::string_view& message, std::source_location location = std::source_location::current()) + : dca_exception{ message, location } {}; }; /// @brief Enumeration for different json value types. @@ -454,8 +455,8 @@ namespace discord_core_api { /// @brief Concept for array types excluding etf_serializer. template - concept array_t = jsonifier::concepts::range && jsonifier::concepts::has_resize> && - jsonifier::concepts::has_emplace_back> && jsonifier::concepts::vector_subscriptable> && + concept array_t = jsonifier::concepts::has_range && jsonifier::concepts::has_resize> && + jsonifier::concepts::has_emplace_back> && jsonifier::concepts::vector_subscriptable> && requires(value_type&& data) { typename value_type::value_type; }; /// @brief Concept for object (associative container) types excluding etf_serializer. @@ -463,7 +464,7 @@ namespace discord_core_api { concept object_t = requires(value_type data) { typename value_type::mapped_type; typename value_type::key_type; - } && jsonifier::concepts::range; + } && jsonifier::concepts::has_range; class etf_serializer { public: @@ -476,53 +477,13 @@ namespace discord_core_api { using int_type = int64_t; using bool_type = bool; - DCA_INLINE etf_serializer() = default; + DCA_INLINE etf_serializer(){ + value = std::nullptr_t{}; + }; DCA_INLINE etf_serializer& operator=(etf_serializer&& data) noexcept { - destroy(); - stringReal = std::move(data.stringReal); - type = data.type; - data.type = json_type::null_t; - switch (type) { - case json_type::object_t: { - objectValue = data.objectValue; - data.objectValue = nullptr; - break; - } - case json_type::array_t: { - arrayValue = data.arrayValue; - data.arrayValue = nullptr; - break; - } - case json_type::string_t: { - stringValue = data.stringValue; - data.stringValue = nullptr; - break; - } - case json_type::float_t: { - floatValue = data.floatValue; - data.floatValue = nullptr; - break; - } - case json_type::int_t: { - intValue = data.intValue; - data.intValue = nullptr; - break; - } - case json_type::uint_t: { - uintValue = data.uintValue; - data.uintValue = nullptr; - break; - } - case json_type::bool_t: { - boolValue = data.boolValue; - data.boolValue = nullptr; - break; - } - case json_type::null_t: { - break; - } - } + stringReal.swap(data.stringReal); + value.swap(data.value); return *this; } @@ -531,40 +492,7 @@ namespace discord_core_api { } DCA_INLINE etf_serializer& operator=(const etf_serializer& data) { - destroy(); - switch (data.type) { - case json_type::object_t: { - setValue(data.getObject()); - break; - } - case json_type::array_t: { - setValue(data.getArray()); - break; - } - case json_type::string_t: { - setValue(data.getString()); - break; - } - case json_type::float_t: { - setValue(data.getFloat()); - break; - } - case json_type::uint_t: { - setValue(data.getUint()); - break; - } - case json_type::int_t: { - setValue(data.getInt()); - break; - } - case json_type::bool_t: { - setValue(data.getBool()); - break; - } - case json_type::null_t: { - break; - } - } + value = data.value; stringReal = data.stringReal; return *this; } @@ -574,7 +502,7 @@ namespace discord_core_api { } template DCA_INLINE etf_serializer& operator=(value_type&& data) noexcept { - setValue(std::forward(data)); + value = std::forward(data); return *this; } @@ -583,7 +511,7 @@ namespace discord_core_api { } template DCA_INLINE etf_serializer& operator=(value_type&& data) noexcept { - setValue(std::forward(data)); + value = std::forward(data); return *this; } @@ -592,7 +520,7 @@ namespace discord_core_api { } template DCA_INLINE etf_serializer& operator=(value_type&& data) noexcept { - setValue(std::forward(data)); + value = std::forward(data); return *this; } @@ -601,7 +529,7 @@ namespace discord_core_api { } template DCA_INLINE etf_serializer& operator=(const char (&str)[str_length]) { - setValue(str); + value = str; return *this; } @@ -609,20 +537,20 @@ namespace discord_core_api { *this = str; } - template DCA_INLINE etf_serializer& operator=(value_type&& data) { - setValue(std::forward(data)); + template DCA_INLINE etf_serializer& operator=(value_type&& data) { + value = std::forward(data); return *this; } - template DCA_INLINE etf_serializer(value_type&& data) { + template DCA_INLINE etf_serializer(value_type&& data) { *this = std::forward(data); } template DCA_INLINE etf_serializer& operator=(value_type&& data) { - if constexpr (jsonifier::concepts::signed_type) { - setValue(std::forward(data)); - } else if constexpr (jsonifier::concepts::unsigned_type) { - setValue(std::forward(data)); + if constexpr (jsonifier::concepts::signed_t) { + value = static_cast(std::forward(data)); + } else if constexpr (jsonifier::concepts::unsigned_t) { + value = static_cast(std::forward(data)); } return *this; } @@ -632,7 +560,7 @@ namespace discord_core_api { } template DCA_INLINE etf_serializer& operator=(value_type&& data) { - setValue(std::forward(data)); + value = std::forward(data); return *this; } @@ -641,7 +569,7 @@ namespace discord_core_api { } template DCA_INLINE etf_serializer& operator=(value_type&& data) noexcept { - setValue(static_cast(std::forward(data))); + value = static_cast(std::forward(data)); return *this; } @@ -650,38 +578,37 @@ namespace discord_core_api { } DCA_INLINE etf_serializer& operator=(json_type data) { - destroy(); switch (data) { case json_type::object_t: { - setValue(); + value = object_type{}; break; } case json_type::array_t: { - setValue(); + value = array_type{}; break; } case json_type::string_t: { - setValue(); + value = string_type{}; break; } case json_type::float_t: { - setValue(); + value = float_type{}; break; } case json_type::uint_t: { - setValue(); + value = uint_type{}; break; } case json_type::int_t: { - setValue(); + value = int_type{}; break; } case json_type::bool_t: { - setValue(); + value = bool_type{}; break; } case json_type::null_t: { - setValue(); + value = nullptr_t{}; break; } } @@ -693,7 +620,23 @@ namespace discord_core_api { } DCA_INLINE json_type getType() const { - return type; + if (std::holds_alternative(value)) { + return json_type::object_t; + } else if (std::holds_alternative(value)) { + return json_type::array_t; + } else if (std::holds_alternative(value)) { + return json_type::string_t; + } else if (std::holds_alternative(value)) { + return json_type::float_t; + } else if (std::holds_alternative(value)) { + return json_type::uint_t; + } else if (std::holds_alternative(value)) { + return json_type::int_t; + } else if (std::holds_alternative(value)) { + return json_type::bool_t; + } else { + return json_type::null_t; + } } DCA_INLINE operator jsonifier::string_base() { @@ -704,22 +647,22 @@ namespace discord_core_api { } DCA_INLINE etf_serializer& operator[](typename object_type::key_type&& key) { - if (type == json_type::null_t) { - setValue(); + if (getType() == json_type::null_t) { + value = object_type{}; } - if (type == json_type::object_t) { + if (getType() == json_type::object_t) { return getObject().operator[](std::forward(key)); } throw etf_serialize_error{ "Sorry, but this value's type is not object." }; } DCA_INLINE etf_serializer& operator[](uint_type index) { - if (type == json_type::null_t) { - setValue(); + if (getType() == json_type::null_t) { + value = array_type{}; } - if (type == json_type::array_t) { + if (getType() == json_type::array_t) { if (index >= getArray().size()) { getArray().resize(index + 1); } @@ -730,11 +673,11 @@ namespace discord_core_api { } DCA_INLINE void emplaceBack(etf_serializer&& data) { - if (type == json_type::null_t) { - setValue(); + if (getType() == json_type::null_t) { + value = array_type{}; } - if (type == json_type::array_t) { + if (getType() == json_type::array_t) { getArray().emplace_back(std::move(data)); return; } @@ -742,11 +685,11 @@ namespace discord_core_api { } DCA_INLINE void emplaceBack(const etf_serializer& rhs) { - if (type == json_type::null_t) { - setValue(); + if (getType() == json_type::null_t) { + value = array_type{}; } - if (type == json_type::array_t) { + if (getType() == json_type::array_t) { getArray().emplace_back(rhs); return; } @@ -754,106 +697,118 @@ namespace discord_core_api { } DCA_INLINE bool_type operator==(const etf_serializer& rhs) const { - if (rhs.type != type) { + if (rhs.getType() != getType()) { return false; } - switch (type) { - case json_type::object_t: { - return *objectValue == *rhs.objectValue; - } - case json_type::array_t: { - return *arrayValue == *rhs.arrayValue; - } - case json_type::string_t: { - return *stringValue == *rhs.stringValue; - } - case json_type::float_t: { - return *floatValue == *rhs.floatValue; - } - case json_type::uint_t: { - return *uintValue == *rhs.uintValue; - } - case json_type::int_t: { - return *intValue == *rhs.intValue; - } - case json_type::bool_t: { - return *boolValue == *rhs.boolValue; - } - case json_type::null_t: { - break; - } - } - return true; + return value == rhs.value; } - DCA_INLINE object_type& getObject() const { - if (type != json_type::object_t) { + DCA_INLINE object_type& getObject() { + if (getType() != json_type::object_t) { throw etf_serialize_error{ "Sorry, but this value's type is not object!" }; } - return *objectValue; + return std::get(value); } - DCA_INLINE array_type& getArray() const { - if (type != json_type::array_t) { + DCA_INLINE array_type& getArray() { + if (getType() != json_type::array_t) { throw etf_serialize_error{ "Sorry, but this value's type is not array!" }; } - return *arrayValue; + return std::get(value); } - DCA_INLINE string_type& getString() const { - if (type != json_type::string_t) { + DCA_INLINE string_type& getString() { + if (getType() != json_type::string_t) { throw etf_serialize_error{ "Sorry, but this value's type is not string!" }; } - return *stringValue; + return std::get(value); } - DCA_INLINE float_type& getFloat() const { - if (type != json_type::float_t) { + DCA_INLINE float_type& getFloat() { + if (getType() != json_type::float_t) { throw etf_serialize_error{ "Sorry, but this value's type is not float!" }; } - return *floatValue; + return std::get(value); } - DCA_INLINE uint_type& getUint() const { - if (type != json_type::uint_t) { + DCA_INLINE uint_type& getUint() { + if (getType() != json_type::uint_t) { throw etf_serialize_error{ "Sorry, but this value's type is not uint!" }; } - return *uintValue; + return std::get(value); } - DCA_INLINE int_type& getInt() const { - if (type != json_type::int_t) { + DCA_INLINE int_type& getInt() { + if (getType() != json_type::int_t) { throw etf_serialize_error{ "Sorry, but this value's type is not int!" }; } - return *intValue; + return std::get(value); } - DCA_INLINE bool_type& getBool() const { - if (type != json_type::bool_t) { + DCA_INLINE bool_type& getBool() { + if (getType() != json_type::bool_t) { throw etf_serialize_error{ "Sorry, but this value's type is not bool!" }; } - return *boolValue; + return std::get(value); } - DCA_INLINE ~etf_serializer() { - destroy(); + DCA_INLINE const object_type& getObject() const { + if (getType() != json_type::object_t) { + throw etf_serialize_error{ "Sorry, but this value's type is not object!" }; + } + return std::get(value); } + DCA_INLINE const array_type& getArray() const { + if (getType() != json_type::array_t) { + throw etf_serialize_error{ "Sorry, but this value's type is not array!" }; + } + return std::get(value); + } + + DCA_INLINE const string_type& getString() const { + if (getType() != json_type::string_t) { + throw etf_serialize_error{ "Sorry, but this value's type is not string!" }; + } + return std::get(value); + } + + DCA_INLINE const float_type& getFloat() const { + if (getType() != json_type::float_t) { + throw etf_serialize_error{ "Sorry, but this value's type is not float!" }; + } + return std::get(value); + } + + DCA_INLINE const uint_type& getUint() const { + if (getType() != json_type::uint_t) { + throw etf_serialize_error{ "Sorry, but this value's type is not uint!" }; + } + return std::get(value); + } + + DCA_INLINE const int_type& getInt() const { + if (getType() != json_type::int_t) { + throw etf_serialize_error{ "Sorry, but this value's type is not int!" }; + } + return std::get(value); + } + + DCA_INLINE const bool_type& getBool() const { + if (getType() != json_type::bool_t) { + throw etf_serialize_error{ "Sorry, but this value's type is not bool!" }; + } + return std::get(value); + } + + DCA_INLINE ~etf_serializer() = default; + protected: jsonifier::string_base stringReal{}; - json_type type{ json_type::null_t }; - union { - object_type* objectValue; - array_type* arrayValue; - string_type* stringValue; - float_type* floatValue; - uint_type* uintValue; - int_type* intValue; - bool_type* boolValue; - }; + std::variant value{}; DCA_INLINE void serializeJsonToEtfString(const etf_serializer& dataToParse) { - switch (dataToParse.type) { + switch (dataToParse.getType()) { case json_type::object_t: { return writeEtfObject(dataToParse.getObject()); } @@ -1043,101 +998,6 @@ namespace discord_core_api { uint8_t newBuffer[5]{ static_cast(etf_type::Small_Atom_Ext), static_cast(3), 'n', 'i', 'l' }; writeString(newBuffer, std::size(newBuffer)); } - - template DCA_INLINE void setValue(value_types&&... args) { - destroy(); - type = typeNew; - if constexpr (typeNew == json_type::object_t) { - allocator alloc{}; - objectValue = alloc.allocate(1); - alloc.construct(objectValue, std::forward(args)...); - } else if constexpr (typeNew == json_type::array_t) { - allocator alloc{}; - arrayValue = alloc.allocate(1); - alloc.construct(arrayValue, std::forward(args)...); - } else if constexpr (typeNew == json_type::string_t) { - allocator alloc{}; - stringValue = alloc.allocate(1); - alloc.construct(stringValue, std::forward(args)...); - } else if constexpr (typeNew == json_type::float_t) { - allocator alloc{}; - floatValue = alloc.allocate(1); - alloc.construct(floatValue, std::forward(args)...); - } else if constexpr (typeNew == json_type::uint_t) { - allocator alloc{}; - uintValue = alloc.allocate(1); - alloc.construct(uintValue, std::forward(args)...); - } else if constexpr (typeNew == json_type::int_t) { - allocator alloc{}; - intValue = alloc.allocate(1); - alloc.construct(intValue, std::forward(args)...); - } else if constexpr (typeNew == json_type::bool_t) { - allocator alloc{}; - boolValue = alloc.allocate(1); - alloc.construct(boolValue, std::forward(args)...); - } - } - - DCA_INLINE void destroy() { - switch (type) { - case json_type::object_t: { - allocator alloc{}; - alloc.destroy(objectValue); - alloc.deallocate(static_cast(objectValue)); - objectValue = nullptr; - break; - } - case json_type::array_t: { - allocator alloc{}; - alloc.destroy(arrayValue); - alloc.deallocate(static_cast(arrayValue)); - arrayValue = nullptr; - break; - } - case json_type::string_t: { - allocator alloc{}; - alloc.destroy(stringValue); - alloc.deallocate(static_cast(stringValue)); - stringValue = nullptr; - break; - } - case json_type::float_t: { - allocator alloc{}; - alloc.destroy(floatValue); - alloc.deallocate(static_cast(floatValue)); - floatValue = nullptr; - break; - } - case json_type::uint_t: { - allocator alloc{}; - alloc.destroy(uintValue); - alloc.deallocate(static_cast(uintValue)); - uintValue = nullptr; - break; - } - case json_type::int_t: { - allocator alloc{}; - alloc.destroy(intValue); - alloc.deallocate(static_cast(intValue)); - intValue = nullptr; - break; - } - case json_type::bool_t: { - allocator alloc{}; - alloc.destroy(boolValue); - alloc.deallocate(static_cast(boolValue)); - boolValue = nullptr; - break; - } - case json_type::null_t: { - break; - } - default: { - break; - } - } - type = json_type::null_t; - } }; /**@}*/ diff --git a/Include/discordcoreapi/Utilities/RingBuffer.hpp b/Include/discordcoreapi/Utilities/RingBuffer.hpp index a7134eba6..90de1f4bd 100644 --- a/Include/discordcoreapi/Utilities/RingBuffer.hpp +++ b/Include/discordcoreapi/Utilities/RingBuffer.hpp @@ -63,10 +63,10 @@ namespace discord_core_api { arrayValue.resize(size); } - DCA_INLINE ring_buffer_interface& operator=(ring_buffer_interface&&) noexcept = default; - DCA_INLINE ring_buffer_interface(ring_buffer_interface&&) noexcept = default; - DCA_INLINE ring_buffer_interface& operator=(const ring_buffer_interface&) noexcept = default; - DCA_INLINE ring_buffer_interface(const ring_buffer_interface&) noexcept = default; + DCA_INLINE ring_buffer_interface& operator=(ring_buffer_interface&&) noexcept = default; + DCA_INLINE ring_buffer_interface(ring_buffer_interface&&) noexcept = default; + DCA_INLINE ring_buffer_interface& operator=(const ring_buffer_interface&) noexcept = default; + DCA_INLINE ring_buffer_interface(const ring_buffer_interface&) noexcept = default; // forward declaration to grant friendship to the ring_buffer class. template friend class ring_buffer; @@ -125,7 +125,7 @@ namespace discord_core_api { } protected: - jsonifier::vector> arrayValue{};///< The underlying data array. + jsonifier::vector> arrayValue{};///< The underlying data array. size_type tail{};///< The tail position in the buffer. size_type head{};///< The head position in the buffer. }; @@ -134,18 +134,18 @@ namespace discord_core_api { /// @tparam value_type the type of data stored in the buffer. /// @tparam slice_count the number of slices. template class ring_buffer - : public ring_buffer_interface, 1024 * 16>, slice_count> { + : public ring_buffer_interface, 1024 * 16>, slice_count> { public: - using base_type = ring_buffer_interface, 1024 * 16>, slice_count>; - using value_type = typename ring_buffer_interface, 1024 * 16>::value_type; + using base_type = ring_buffer_interface, 1024 * 16>, slice_count>; + using value_type = typename ring_buffer_interface, 1024 * 16>::value_type; using const_pointer = const value_type*; using pointer = value_type*; using size_type = uint64_t; /// @brief Default constructor. initializes the buffer size. - DCA_INLINE ring_buffer() noexcept = default; - DCA_INLINE ring_buffer& operator=(ring_buffer&&) noexcept = default; - DCA_INLINE ring_buffer(ring_buffer&&) noexcept = default; + DCA_INLINE ring_buffer() noexcept = default; + DCA_INLINE ring_buffer& operator=(ring_buffer&&) noexcept = default; + DCA_INLINE ring_buffer(ring_buffer&&) noexcept = default; DCA_INLINE ring_buffer& operator=(const ring_buffer&) noexcept = default; DCA_INLINE ring_buffer(const ring_buffer&) noexcept = default; @@ -166,11 +166,11 @@ namespace discord_core_api { /// @brief Read data from the buffer. /// @return a string view containing the read data. - DCA_INLINE jsonifier::string_view_base> readData() { - jsonifier::string_view_base> returnData{}; + DCA_INLINE jsonifier::string_view_base> readData() { + jsonifier::string_view_base> returnData{}; if (base_type::getCurrentTail()->getUsedSpace() > 0) { - returnData = jsonifier::string_view_base>{ base_type::getCurrentTail()->getCurrentTail(), - base_type::getCurrentTail()->getUsedSpace() }; + returnData = + jsonifier::string_view_base>{ base_type::getCurrentTail()->getCurrentTail(), base_type::getCurrentTail()->getUsedSpace() }; base_type::getCurrentTail()->clear(); base_type::modifyReadOrWritePosition(ring_buffer_access_type::read, 1); } diff --git a/Include/discordcoreapi/Utilities/UnboundedMessageBlock.hpp b/Include/discordcoreapi/Utilities/UnboundedMessageBlock.hpp index d938b6670..c4c2029ca 100644 --- a/Include/discordcoreapi/Utilities/UnboundedMessageBlock.hpp +++ b/Include/discordcoreapi/Utilities/UnboundedMessageBlock.hpp @@ -34,7 +34,7 @@ namespace discord_core_api { template - concept copyable_or_movable = std::copyable> || std::movable>; + concept copyable_or_movable = std::copyable> || std::movable>; /// @brief A thread-safe messaging block for data-structures. /// @tparam value_type the type of object that will be sent over the message block. @@ -87,7 +87,7 @@ namespace discord_core_api { std::mutex accessMutex{}; }; - template DCA_INLINE bool waitForTimeToPass(unbounded_message_block>& outBuffer, value_type& argOne, uint64_t timeInMsNew) { + template DCA_INLINE bool waitForTimeToPass(unbounded_message_block>& outBuffer, value_type& argOne, uint64_t timeInMsNew) { stop_watch stopWatch{ milliseconds{ timeInMsNew } }; stopWatch.reset(); while (!outBuffer.tryReceive(argOne)) { diff --git a/Include/discordcoreapi/Utilities/UnorderedSet.hpp b/Include/discordcoreapi/Utilities/UnorderedSet.hpp index bfa465513..033e7bff2 100644 --- a/Include/discordcoreapi/Utilities/UnorderedSet.hpp +++ b/Include/discordcoreapi/Utilities/UnorderedSet.hpp @@ -36,7 +36,7 @@ namespace discord_core_api { template class unordered_set; template - concept set_container_iterator_t = std::same_as::iterator, jsonifier_internal::unwrap_t>; + concept set_container_iterator_t = std::same_as::iterator, std::remove_cvref_t>; template class unordered_set : protected hash_policy>, protected jsonifier_internal::alloc_wrapper, protected object_compare { @@ -309,7 +309,7 @@ namespace discord_core_api { } template DCA_INLINE uint64_t getKey(value_type_newer&& keyValue) const { - return key_accessor>::getHashKey(std::forward(keyValue)); + return key_accessor>::getHashKey(std::forward(keyValue)); } DCA_INLINE void resize(size_type capacityNew) { diff --git a/Include/discordcoreapi/Utilities/WebSocketClient.hpp b/Include/discordcoreapi/Utilities/WebSocketClient.hpp index 025d4a255..59f02f4a0 100644 --- a/Include/discordcoreapi/Utilities/WebSocketClient.hpp +++ b/Include/discordcoreapi/Utilities/WebSocketClient.hpp @@ -234,7 +234,7 @@ namespace discord_core_api { }; /// @brief A websocket client, for communication via a tcp-connection. - class websocket_client : public websocket_core { + class DiscordCoreAPI_Dll websocket_client : public websocket_core { public: friend struct discord_core_api::on_voice_server_update_data; friend struct discord_core_api::on_voice_state_update_data; @@ -275,7 +275,7 @@ namespace discord_core_api { snowflake userId{}; }; - class base_socket_agent { + class DiscordCoreAPI_Dll base_socket_agent { public: friend class discord_core_api::discord_core_client; friend class discord_core_api::bot_user; diff --git a/Library/CMake/BuildFeatureTester.bat b/Library/CMake/BuildFeatureTester.bat deleted file mode 100644 index 62c7a1dd1..000000000 --- a/Library/CMake/BuildFeatureTester.bat +++ /dev/null @@ -1,2 +0,0 @@ -"C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe" -S ./ -B ./Build -DCMAKE_BUILD_TYPE=Release -"C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe" --build ./Build --config=Release \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index 0f946bc58..70c83c5ad 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,6 +1,6 @@ # DiscordCoreAPI [![Codacy Badge](https://img.shields.io/codacy/grade/1e5ae970aed34d0b96249cdfd02099cf?color=lightblue&label=Code%20Quality&style=plastic)](https://www.codacy.com/gh/RealTimeChris/DiscordCoreAPI/dashboard?utm_source=github.com&utm_medium=referral&utm_content=RealTimeChris/DiscordCoreAPI&utm_campaign=Badge_Grade) -[![Discord](https://img.shields.io/discord/931640556814237706?color=red&label=Discord%20Server&style=plastic)](https://discord.gg/adgMqeBuhP) +[![Discord](https://img.shields.io/discord/931640556814237706?color=red&label=Discord%20Server&style=plastic)](https://discord.gg/c33GH5BUe8) ![Commit Activity](https://img.shields.io/github/commit-activity/y/realtimechris/discordcoreapi?color=green&label=Commits&style=plastic) ![Lines of Code](https://tokei.rs/b1/github/RealTimeChris/DiscordCoreAPI-Code-Only?color=light-blue&label=Lines%20Of%20Code%20&style=plastic) @@ -11,20 +11,20 @@ Hello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in alt="DiscordCoreAPI WebSite" width="500"/>

## Compiler Support -![MSVC_20922](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC_2022-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=MSVC_2022&labelColor=pewter&color=blue) -![CLANG_18](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG_18-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=CLANG_18&labelColor=pewter&color=blue) -![GCC_13](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC_13-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=GCC_13&labelColor=pewter&color=blue) +![MSVC_20922](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=MSVC_2022&labelColor=pewter&color=blue) +![CLANG_18](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=CLANG_18&labelColor=pewter&color=blue) +![GCC_13](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=GCC_13&labelColor=pewter&color=blue) ## Operating System Support -![Windows](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC_2022-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=Windows&labelColor=pewter&color=blue) -![Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG_18-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=Linux&labelColor=pewter&color=blue) -![Mac](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC_13-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=MacOS&labelColor=pewter&color=blue) +![Windows](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC-Windows.yml?style=plastic&logo=microsoft&logoColor=green&label=Windows&labelColor=pewter&color=blue) +![Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG-Ubuntu.yml?style=plastic&logo=linux&logoColor=green&label=Linux&labelColor=pewter&color=blue) +![Mac](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC-MacOS.yml?style=plastic&logo=apple&logoColor=green&label=MacOS&labelColor=pewter&color=blue) # Documentation/Examples [Documentation/Examples](https://discordcoreapi.com/documentation_examples.html) # Discord Server -[This is a link to the Discord server!](https://discord.gg/adgMqeBuhP) +[This is a link to the Discord server!](https://discord.gg/c33GH5BUe8) # Bot Template [A template for utilizing this library.](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI) diff --git a/Source/EventManager.cpp b/Source/EventManager.cpp index daf1d24cf..24e155768 100644 --- a/Source/EventManager.cpp +++ b/Source/EventManager.cpp @@ -186,7 +186,7 @@ namespace discord_core_api { template<> unordered_map*> object_collector::objectsBuffersMap; on_input_event_creation_data::on_input_event_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -196,7 +196,7 @@ namespace discord_core_api { on_application_command_permissions_update_data::on_application_command_permissions_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -205,7 +205,7 @@ namespace discord_core_api { } on_auto_moderation_rule_creation_data::on_auto_moderation_rule_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -214,7 +214,7 @@ namespace discord_core_api { } on_auto_moderation_rule_update_data::on_auto_moderation_rule_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -223,7 +223,7 @@ namespace discord_core_api { } on_auto_moderation_rule_deletion_data::on_auto_moderation_rule_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -232,7 +232,7 @@ namespace discord_core_api { } on_auto_moderation_action_execution_data::on_auto_moderation_action_execution_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -241,7 +241,7 @@ namespace discord_core_api { } on_channel_creation_data::on_channel_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -258,7 +258,7 @@ namespace discord_core_api { } on_channel_update_data::on_channel_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (channels::doWeCacheChannels()) { oldValue = channels::getCachedChannel({ .channelId = value.id }); channels::insertChannel(static_cast(value)); @@ -266,7 +266,7 @@ namespace discord_core_api { } on_channel_deletion_data::on_channel_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -287,7 +287,7 @@ namespace discord_core_api { } on_channel_pins_update_data::on_channel_pins_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -296,7 +296,7 @@ namespace discord_core_api { } on_thread_creation_data::on_thread_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -305,7 +305,7 @@ namespace discord_core_api { } on_thread_update_data::on_thread_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -314,7 +314,7 @@ namespace discord_core_api { } on_thread_deletion_data::on_thread_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -323,7 +323,7 @@ namespace discord_core_api { } on_thread_list_sync_data::on_thread_list_sync_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -332,7 +332,7 @@ namespace discord_core_api { } on_thread_member_update_data::on_thread_member_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -341,7 +341,7 @@ namespace discord_core_api { } on_thread_members_update_data::on_thread_members_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -350,7 +350,7 @@ namespace discord_core_api { } on_guild_creation_data::on_guild_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -416,7 +416,7 @@ namespace discord_core_api { } on_guild_update_data::on_guild_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (guilds::doWeCacheGuilds()) { oldValue = guilds::getCachedGuild({ value.id }); guilds::insertGuild(static_cast(value)); @@ -424,7 +424,7 @@ namespace discord_core_api { } on_guild_deletion_data::on_guild_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -445,7 +445,7 @@ namespace discord_core_api { } on_guild_ban_add_data::on_guild_ban_add_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -462,7 +462,7 @@ namespace discord_core_api { } on_guild_ban_remove_data::on_guild_ban_remove_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -471,7 +471,7 @@ namespace discord_core_api { } on_guild_emojis_update_data::on_guild_emojis_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -486,7 +486,7 @@ namespace discord_core_api { } on_guild_stickers_update_data::on_guild_stickers_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -495,7 +495,7 @@ namespace discord_core_api { } on_guild_integrations_update_data::on_guild_integrations_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -504,7 +504,7 @@ namespace discord_core_api { } on_guild_member_add_data::on_guild_member_add_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -522,7 +522,7 @@ namespace discord_core_api { } on_guild_member_remove_data::on_guild_member_remove_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -545,7 +545,7 @@ namespace discord_core_api { } on_guild_member_update_data::on_guild_member_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (guild_members::doWeCacheGuildMembers()) { oldValue = guild_members::getCachedGuildMember({ .guildMemberId = value.user.id, .guildId = value.guildId }); guild_members::insertGuildMember(static_cast(value)); @@ -553,7 +553,7 @@ namespace discord_core_api { } on_guild_members_chunk_data::on_guild_members_chunk_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -562,7 +562,7 @@ namespace discord_core_api { } on_role_creation_data::on_role_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -579,7 +579,7 @@ namespace discord_core_api { } on_role_update_data::on_role_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (roles::doWeCacheRoles()) { oldValue = roles::getCachedRole({ .guildId = value.guildId, .roleId = value.role.id }); roles::insertRole(static_cast(value.role)); @@ -587,7 +587,7 @@ namespace discord_core_api { } on_role_deletion_data::on_role_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -609,7 +609,7 @@ namespace discord_core_api { on_voice_server_update_data::on_voice_server_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse, discord_core_internal::websocket_client* sslShard) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -633,7 +633,7 @@ namespace discord_core_api { }; on_guild_scheduled_event_creation_data::on_guild_scheduled_event_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -642,7 +642,7 @@ namespace discord_core_api { } on_guild_scheduled_event_update_data::on_guild_scheduled_event_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -651,7 +651,7 @@ namespace discord_core_api { } on_guild_scheduled_event_deletion_data::on_guild_scheduled_event_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -660,7 +660,7 @@ namespace discord_core_api { } on_guild_scheduled_event_user_add_data::on_guild_scheduled_event_user_add_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -669,7 +669,7 @@ namespace discord_core_api { } on_guild_scheduled_event_user_remove_data::on_guild_scheduled_event_user_remove_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -678,7 +678,7 @@ namespace discord_core_api { } on_integration_creation_data::on_integration_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -687,7 +687,7 @@ namespace discord_core_api { } on_integration_update_data::on_integration_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -696,7 +696,7 @@ namespace discord_core_api { } on_integration_deletion_data::on_integration_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -705,7 +705,7 @@ namespace discord_core_api { } on_interaction_creation_data::on_interaction_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -789,7 +789,7 @@ namespace discord_core_api { } on_invite_creation_data::on_invite_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -798,7 +798,7 @@ namespace discord_core_api { } on_invite_deletion_data::on_invite_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -807,7 +807,7 @@ namespace discord_core_api { } on_message_creation_data::on_message_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -819,7 +819,7 @@ namespace discord_core_api { } on_message_update_data::on_message_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -831,7 +831,7 @@ namespace discord_core_api { } on_message_deletion_data::on_message_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -840,7 +840,7 @@ namespace discord_core_api { } on_message_delete_bulk_data::on_message_delete_bulk_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -849,7 +849,7 @@ namespace discord_core_api { } on_reaction_add_data::on_reaction_add_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -861,7 +861,7 @@ namespace discord_core_api { } on_reaction_remove_data::on_reaction_remove_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -870,7 +870,7 @@ namespace discord_core_api { } on_reaction_remove_all_data::on_reaction_remove_all_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -879,7 +879,7 @@ namespace discord_core_api { } on_reaction_remove_emoji_data::on_reaction_remove_emoji_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -888,7 +888,7 @@ namespace discord_core_api { } on_presence_update_data::on_presence_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -897,7 +897,7 @@ namespace discord_core_api { } on_stage_instance_creation_data::on_stage_instance_creation_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -906,7 +906,7 @@ namespace discord_core_api { } on_stage_instance_update_data::on_stage_instance_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -915,7 +915,7 @@ namespace discord_core_api { } on_stage_instance_deletion_data::on_stage_instance_deletion_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -924,7 +924,7 @@ namespace discord_core_api { } on_typing_start_data::on_typing_start_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -933,7 +933,7 @@ namespace discord_core_api { } on_user_update_data::on_user_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); oldValue = users::getCachedUser({ value.id }); if (users::doWeCacheUsers()) { users::insertUser(static_cast(value)); @@ -942,7 +942,7 @@ namespace discord_core_api { on_voice_state_update_data::on_voice_state_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse, discord_core_internal::websocket_client* sslShard) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -970,7 +970,7 @@ namespace discord_core_api { } on_webhook_update_data::on_webhook_update_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -979,7 +979,7 @@ namespace discord_core_api { } on_auto_complete_entry_data::on_auto_complete_entry_data(jsonifier::jsonifier_core& parserNew, jsonifier::string_view_base dataToParse) { - parserNew.parseJson(*static_cast(this), dataToParse); + parserNew.parseJson(*static_cast(this), dataToParse); if (auto result = parserNew.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); diff --git a/Source/FoundationEntities.cpp b/Source/FoundationEntities.cpp index bb07d8631..0c2164ad1 100644 --- a/Source/FoundationEntities.cpp +++ b/Source/FoundationEntities.cpp @@ -890,7 +890,7 @@ namespace discord_core_api { application_command_option_choice_data choiceData{}; choiceData.nameLocalizations = theNameLocalizations; choiceData.name = theName; - choiceData.value = jsonifier::string{ value.operator jsonifier::string_base() }; + choiceData.value = jsonifier::raw_json_data{ parser, value.operator jsonifier::string_base() }; choices.emplace_back(choiceData); return *this; } @@ -1061,13 +1061,13 @@ namespace discord_core_api { commandName = inputEventData.interactionData->data.name; } if (inputEventData.interactionData->data.targetId != 0) { - optionsArgs.values.emplace("target_id", jsonifier::raw_json_data{ inputEventData.interactionData->data.targetId.operator jsonifier::string() }); + optionsArgs.values.emplace("target_id", jsonifier::raw_json_data{ parser, inputEventData.interactionData->data.targetId.operator jsonifier::string() }); } else if (inputEventData.interactionData->data.targetId != 0) { - optionsArgs.values.emplace("target_id", jsonifier::raw_json_data{ inputEventData.interactionData->data.targetId.operator jsonifier::string() }); + optionsArgs.values.emplace("target_id", jsonifier::raw_json_data{ parser, inputEventData.interactionData->data.targetId.operator jsonifier::string() }); } eventData = makeUnique(inputEventData); for (auto& value: eventData->interactionData->data.options) { - jsonifier::raw_json_data serializer{ value.value.operator jsonifier::string() }; + jsonifier::raw_json_data serializer{ parser, value.value.get() }; optionsArgs.values[value.name] = serializer; parseCommandDataOption(optionsArgs.values, value); } diff --git a/Source/SoundCloudAPI.cpp b/Source/SoundCloudAPI.cpp index bec68ad17..496b7db69 100644 --- a/Source/SoundCloudAPI.cpp +++ b/Source/SoundCloudAPI.cpp @@ -118,23 +118,23 @@ namespace discord_core_api { (returnData.responseData.find("window.__sc_hydration = ") + jsonifier::string{ "window.__sc_hydration = " }.size())); } welcome resultsNew{}; - parser.parseJson(resultsNew, returnData.responseData); + parser.parseJson(resultsNew, returnData.responseData); jsonifier::string avatarUrl{}; jsonifier::string collectionString{ "tracks?ids=" }; for (auto& value: resultsNew.data) { if (value.data.getType() == jsonifier::json_type::Object) { - auto newObject = value.data.operator jsonifier::raw_json_data::object_type(); - avatarUrl = newObject["avatar_url"].operator jsonifier::string(); + auto newObject = value.data.get(); + avatarUrl = newObject["avatar_url"].get(); if (value.hydratable == "playlist") { - auto newerObject = value.data.operator jsonifier::raw_json_data::object_type(); + auto newerObject = value.data.get(); for (auto& [key, valueNew]: newerObject) { if (key == "tracks") { - auto newArray = valueNew.operator jsonifier::raw_json_data::array_type(); + auto newArray = valueNew.get(); uint32_t currentIndex{}; auto arraySize = newArray.size(); for (auto& newValue: newArray) { - newObject = newValue.operator jsonifier::raw_json_data::object_type(); - collectionString += jsonifier::toString(newValue.operator jsonifier::raw_json_data::object_type()["id"].operator uint64_t()); + newObject = newValue.get(); + collectionString += jsonifier::toString(newValue.get()["id"].get()); if (currentIndex < arraySize - 1) { collectionString += "%2C"; } @@ -153,32 +153,32 @@ namespace discord_core_api { dataPackage02.workloadClass = https_workload_class::Get; returnData = submitWorkloadAndGetResult(std::move(dataPackage02)); jsonifier::vector resultsNewer{}; - parser.parseJson(resultsNewer, returnData.responseData); + parser.parseJson(resultsNewer, returnData.responseData); for (auto& value: resultsNewer) { song results{}; if (value.getType() == jsonifier::json_type::Object) { - auto newObject = value.operator jsonifier::raw_json_data::object_type(); - avatarUrl = newObject["avatar_url"].operator jsonifier::string(); - if (newObject["title"].operator jsonifier::string() == "") { + auto newObject = value.get(); + avatarUrl = newObject["avatar_url"].get(); + if (newObject["title"].get() == "") { continue; } bool isItFound{}; - for (auto& valueNew: newObject["media"].operator jsonifier::raw_json_data::object_type()["transcodings"].operator jsonifier::raw_json_data::array_type()) { - if (valueNew.operator jsonifier::raw_json_data::object_type()["preset"].operator jsonifier::string() == "opus_0_0") { + for (auto& valueNew: newObject["media"].get()["transcodings"].get()) { + if (valueNew.get()["preset"].get() == "opus_0_0") { isItFound = true; - results.firstDownloadUrl = valueNew.operator jsonifier::raw_json_data::object_type()["url"].operator jsonifier::string(); - results.songId = valueNew.operator jsonifier::raw_json_data::object_type()["url"].operator jsonifier::string(); + results.firstDownloadUrl = valueNew.get()["url"].get(); + results.songId = valueNew.get()["url"].get(); } } if (isItFound) { - jsonifier::string newString = newObject["title"].operator jsonifier::string(); + jsonifier::string newString = newObject["title"].get(); if (newString.size() > 0) { if (newString.size() > 256) { newString = newString.substr(0, 256); } results.songTitle = utf8MakeValid(newString); } - newString = newObject["description"].operator jsonifier::string(); + newString = newObject["description"].get(); if (newString.size() > 0) { if (newString.size() > 256) { newString = newString.substr(0, 256); @@ -186,17 +186,17 @@ namespace discord_core_api { results.description = utf8MakeValid(newString); results.description += "..."; } - newString = newObject["artwork_url"].operator jsonifier::string(); + newString = newObject["artwork_url"].get(); if (newString.size() > 0) { results.thumbnailUrl = utf8MakeValid(newString); } - results.viewUrl = newObject["permalink_url"].operator jsonifier::string(); - results.duration = time_stamp::convertMsToDurationString(static_cast(newObject["duration"].operator uint64_t())); + results.viewUrl = newObject["permalink_url"].get(); + results.duration = time_stamp::convertMsToDurationString(static_cast(newObject["duration"].get())); results.firstDownloadUrl += - "?client_id=" + sound_cloud_request_builder::clientId + "&track_authorization=" + newObject["track_authorization"].operator jsonifier::string(); - if (newObject["artwork_url"].operator jsonifier::string().find("-") != jsonifier::string::npos) { + "?client_id=" + sound_cloud_request_builder::clientId + "&track_authorization=" + newObject["track_authorization"].get(); + if (newObject["artwork_url"].get().find("-") != jsonifier::string::npos) { jsonifier::string newerString = - newObject["artwork_url"].operator jsonifier::string().substr(0, newObject["artwork_url"].operator jsonifier::string().findLastOf("-") + 1); + newObject["artwork_url"].get().substr(0, newObject["artwork_url"].get().findLastOf("-") + 1); newerString += "t500x500.jpg"; results.thumbnailUrl = newerString; } else if (avatarUrl.find("-") != jsonifier::string::npos) { @@ -235,35 +235,34 @@ namespace discord_core_api { (returnData.responseData.find("window.__sc_hydration = ") + jsonifier::string{ "window.__sc_hydration = " }.size())); } welcome resultsNew{}; - parser.parseJson(resultsNew, returnData.responseData); + parser.parseJson(resultsNew, returnData.responseData); jsonifier::string avatarUrl{}; for (auto& value: resultsNew.data) { if (value.data.getType() == jsonifier::json_type::Object) { - auto newObject = value.data.operator jsonifier::raw_json_data::object_type(); - avatarUrl = newObject["avatar_url"].operator jsonifier::string(); + auto newObject = value.data.get(); + avatarUrl = newObject["avatar_url"].get(); if (value.hydratable == "sound") { - if (newObject["title"].operator jsonifier::string() == "") { + if (newObject["title"].get() == "") { continue; } bool isItFound{}; - for (auto& valueNew: - newObject["media"].operator jsonifier::raw_json_data::object_type()["transcodings"].operator jsonifier::raw_json_data::array_type()) { - if (valueNew.operator jsonifier::raw_json_data::object_type()["preset"].operator jsonifier::string() == "opus_0_0") { + for (auto& valueNew: newObject["media"].get()["transcodings"].get()) { + if (valueNew.get()["preset"].get() == "opus_0_0") { isItFound = true; - results.firstDownloadUrl = valueNew.operator jsonifier::raw_json_data::object_type()["url"].operator jsonifier::string(); - results.songId = valueNew.operator jsonifier::raw_json_data::object_type()["url"].operator jsonifier::string(); + results.firstDownloadUrl = valueNew.get()["url"].get(); + results.songId = valueNew.get()["url"].get(); } } if (isItFound) { - jsonifier::string newString = newObject["title"].operator jsonifier::string(); + jsonifier::string newString = newObject["title"].get(); if (newString.size() > 0) { if (newString.size() > 256) { newString = newString.substr(0, 256); } results.songTitle = utf8MakeValid(newString); } - newString = newObject["description"].operator jsonifier::string(); + newString = newObject["description"].get(); if (newString.size() > 0) { if (newString.size() > 256) { newString = newString.substr(0, 256); @@ -271,17 +270,17 @@ namespace discord_core_api { results.description = utf8MakeValid(newString); results.description += "..."; } - newString = newObject["artwork_url"].operator jsonifier::string(); + newString = newObject["artwork_url"].get(); if (newString.size() > 0) { results.thumbnailUrl = utf8MakeValid(newString); } - results.viewUrl = newObject["permalink_url"].operator jsonifier::string(); - results.duration = time_stamp::convertMsToDurationString(static_cast(newObject["duration"].operator uint64_t())); + results.viewUrl = newObject["permalink_url"].get(); + results.duration = time_stamp::convertMsToDurationString(static_cast(newObject["duration"].get())); results.firstDownloadUrl += - "?client_id=" + sound_cloud_request_builder::clientId + "&track_authorization=" + newObject["track_authorization"].operator jsonifier::string(); - if (newObject["artwork_url"].operator jsonifier::string().find("-") != jsonifier::string::npos) { + "?client_id=" + sound_cloud_request_builder::clientId + "&track_authorization=" + newObject["track_authorization"].get(); + if (newObject["artwork_url"].get().find("-") != jsonifier::string::npos) { jsonifier::string newerString = - newObject["artwork_url"].operator jsonifier::string().substr(0, newObject["artwork_url"].operator jsonifier::string().findLastOf("-") + 1); + newObject["artwork_url"].get().substr(0, newObject["artwork_url"].get().findLastOf("-") + 1); newerString += "t500x500.jpg"; results.thumbnailUrl = newerString; } else if (avatarUrl.find("-") != jsonifier::string::npos) { @@ -325,7 +324,7 @@ namespace discord_core_api { dataPackage.workloadClass = https_workload_class::Get; https_response_data returnData = submitWorkloadAndGetResult(std::move(dataPackage)); sound_cloud_search_results resultsNew{}; - parser.parseJson(resultsNew, returnData.responseData); + parser.parseJson(resultsNew, returnData.responseData); for (auto& value: resultsNew.collection) { song songNew{}; if (value.title == "") { @@ -396,7 +395,7 @@ namespace discord_core_api { https_response_data results = submitWorkloadAndGetResult(std::move(dataPackage01)); second_download_url downloadUrl{}; song newerSong{ songNew }; - parser.parseJson(downloadUrl, results.responseData); + parser.parseJson(downloadUrl, results.responseData); newerSong.secondDownloadUrl = downloadUrl.url; if (newerSong.secondDownloadUrl.find("/playlist") != jsonifier::string::npos) { https_workload_data dataPackage{ https_workload_type::SoundCloud_Get_Download_Links }; diff --git a/Source/VoiceConnection.cpp b/Source/VoiceConnection.cpp index 569a48749..ccaeecbd1 100644 --- a/Source/VoiceConnection.cpp +++ b/Source/VoiceConnection.cpp @@ -410,11 +410,11 @@ namespace discord_core_api { bool voice_connection::onMessageReceived(jsonifier::string_view_base data) { discord_core_internal::websocket_message message{}; message_printer::printSuccess("message received from voice websocket: " + jsonifier::string{ data }); - parser.parseJson(message, data); + parser.parseJson(message, data); switch (static_cast(message.op)) { case voice_socket_op_codes::Ready_Server: { discord_core_internal::websocket_message_data dataNew{}; - parser.parseJson(dataNew, data); + parser.parseJson(dataNew, data); audioSSRC = dataNew.d.ssrc; voiceIp = dataNew.d.ip; port = dataNew.d.port; @@ -429,7 +429,7 @@ namespace discord_core_api { case voice_socket_op_codes::Session_Description: { discord_core_internal::websocket_message_data dataNew{}; encryptionKey.clear(); - parser.parseJson(dataNew, data); + parser.parseJson(dataNew, data); for (auto& value: dataNew.d.secretKey) { encryptionKey.emplace_back(static_cast(value)); } @@ -439,7 +439,7 @@ namespace discord_core_api { } case voice_socket_op_codes::speaking: { discord_core_internal::websocket_message_data dataNew{}; - parser.parseJson(dataNew, data); + parser.parseJson(dataNew, data); const uint32_t ssrc = dataNew.d.ssrc; auto userId = dataNew.d.userId; unique_ptr user{ makeUnique(userId) }; @@ -457,7 +457,7 @@ namespace discord_core_api { } case voice_socket_op_codes::hello: { discord_core_internal::websocket_message_data dataNew{}; - parser.parseJson(dataNew, data); + parser.parseJson(dataNew, data); heartBeatStopWatch = stop_watch{ dataNew.d.heartBeatInterval }; heartBeatStopWatch.reset(); areWeHeartBeating = true; @@ -472,7 +472,7 @@ namespace discord_core_api { } case voice_socket_op_codes::Client_Disconnect: { discord_core_internal::websocket_message_data dataNew{}; - parser.parseJson(dataNew, data); + parser.parseJson(dataNew, data); const auto userId = dataNew.d.userId; for (auto& [key, value]: voiceUsers) { if (userId == value->getUserId()) { diff --git a/Source/WebSocketClient.cpp b/Source/WebSocketClient.cpp index dfbb6cdaf..fa856071a 100644 --- a/Source/WebSocketClient.cpp +++ b/Source/WebSocketClient.cpp @@ -460,12 +460,15 @@ namespace discord_core_api { bool websocket_client::onMessageReceived(jsonifier::string_view_base dataNew) { try { + std::string newString{}; + newString.resize(dataNew.size()); + std::memcpy(newString.data(), dataNew.data(), dataNew.size()); if (areWeConnected() && currentMessage.size() > 0 && dataNew.size() > 0) { websocket_message message{}; if (configManager->getTextFormat() == text_format::etf) { try { dataNew = etfParser.parseEtfToJson(dataNew); - parser.parseJson(message, dataNew); + parser.parseJson(message, dataNew); for (auto& valueNew: parser.getErrors()) { message_printer::printError(valueNew.reportError() + ", for data:" + dataNew); } @@ -476,7 +479,7 @@ namespace discord_core_api { return false; } } else { - parser.parseJson(message, dataNew); + parser.parseJson(message, dataNew); if (auto result = parser.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError() + ", for data:" + dataNew); @@ -484,453 +487,465 @@ namespace discord_core_api { } } - if (message.s != 0) { - lastNumberReceived = static_cast(message.s); + if (message.s.has_value()) { + if (message.s.value() != 0) { + std::cout << "CURRENT TYPE: " << message.s.value() << std::endl; + lastNumberReceived = static_cast(message.s.value()); + } } + + std::cout << "CURRENT TYPE: " << message.op << std::endl; + message_printer::printSuccess("Message received from websocket [" + jsonifier::toString(shard.at(0)) + "," + jsonifier::toString(shard.at(1)) + jsonifier::string("]: ") + jsonifier::string{ dataNew }); switch (static_cast(message.op)) { case websocket_op_codes::dispatch: { - if (message.t != "") { - switch (event_converter{ message.t }) { - case 1: { - websocket_message_data data{}; - if (dataOpCode == websocket_op_code::Op_Text) { - data.d.jsonifierExcludedKeys.emplace("shard"); - } - currentState.store(websocket_state::authenticated, std::memory_order_release); - parser.parseJson(data, dataNew); - if (auto result = parser.getErrors(); result.size() > 0) { - for (auto& valueNew: result) { - message_printer::printError(valueNew.reportError()); + if (message.t.has_value()) { + if (message.t.value() != "") { + std::cout << "CURRENT TYPE: " << message.t.value() << std::endl; + switch (event_converter{ message.t.value() }) { + case 1: { + websocket_message_data data{}; + if (dataOpCode == websocket_op_code::Op_Text) { + data.d.jsonifierExcludedKeys.emplace("shard"); } + currentState.store(websocket_state::authenticated, std::memory_order_release); + parser.parseJson(data, dataNew); + if (auto result = parser.getErrors(); result.size() > 0) { + for (auto& valueNew: result) { + message_printer::printError(valueNew.reportError()); + } + } + sessionId = data.d.sessionId; + if (data.d.resumeGatewayUrl.find("wss://") != jsonifier::string::npos) { + resumeUrl = data.d.resumeGatewayUrl.substr(data.d.resumeGatewayUrl.find("wss://") + jsonifier::string{ "wss://" }.size()); + } + discord_core_client::getInstance()->currentUser = bot_user{ data.d.user, + discord_core_client::getInstance() + ->baseSocketAgentsMap[static_cast(floor(static_cast(shard.at(0)) % + static_cast(discord_core_client::getInstance()->baseSocketAgentsMap.size())))] + .get() }; + users::insertUser(static_cast(std::move(data.d.user))); + currentReconnectTries = 0; + break; } - sessionId = data.d.sessionId; - if (data.d.resumeGatewayUrl.find("wss://") != jsonifier::string::npos) { - resumeUrl = data.d.resumeGatewayUrl.substr(data.d.resumeGatewayUrl.find("wss://") + jsonifier::string{ "wss://" }.size()); + case 2: { + currentState.store(websocket_state::authenticated, std::memory_order_release); + currentReconnectTries = 0; + break; } - discord_core_client::getInstance()->currentUser = bot_user{ data.d.user, - discord_core_client::getInstance() - ->baseSocketAgentsMap[static_cast(floor( - static_cast(shard.at(0)) % static_cast(discord_core_client::getInstance()->baseSocketAgentsMap.size())))] - .get() }; - users::insertUser(static_cast(std::move(data.d.user))); - currentReconnectTries = 0; - break; - } - case 2: { - currentState.store(websocket_state::authenticated, std::memory_order_release); - currentReconnectTries = 0; - break; - } - case 3: { - if (discord_core_client::getInstance()->eventManager.onApplicationCommandPermissionsUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique( - parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onApplicationCommandPermissionsUpdateEvent(*dataPackage); + case 3: { + if (discord_core_client::getInstance()->eventManager.onApplicationCommandPermissionsUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique( + parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onApplicationCommandPermissionsUpdateEvent(*dataPackage); + } + break; } - break; - } - case 4: { - if (discord_core_client::getInstance()->eventManager.onAutoModerationRuleCreationEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onAutoModerationRuleCreationEvent(*dataPackage); + case 4: { + if (discord_core_client::getInstance()->eventManager.onAutoModerationRuleCreationEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onAutoModerationRuleCreationEvent(*dataPackage); + } + break; } - break; - } - case 5: { - if (discord_core_client::getInstance()->eventManager.onAutoModerationRuleUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onAutoModerationRuleUpdateEvent(*dataPackage); + case 5: { + if (discord_core_client::getInstance()->eventManager.onAutoModerationRuleUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onAutoModerationRuleUpdateEvent(*dataPackage); + } + break; } - break; - } - case 6: { - if (discord_core_client::getInstance()->eventManager.onAutoModerationRuleDeletionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onAutoModerationRuleDeletionEvent(*dataPackage); + case 6: { + if (discord_core_client::getInstance()->eventManager.onAutoModerationRuleDeletionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onAutoModerationRuleDeletionEvent(*dataPackage); + } + break; } - break; - } - case 7: { - if (discord_core_client::getInstance()->eventManager.onAutoModerationActionExecutionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, - dataNew) }; - discord_core_client::getInstance()->eventManager.onAutoModerationActionExecutionEvent(*dataPackage); + case 7: { + if (discord_core_client::getInstance()->eventManager.onAutoModerationActionExecutionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, + dataNew) }; + discord_core_client::getInstance()->eventManager.onAutoModerationActionExecutionEvent(*dataPackage); + } + break; } - break; - } - case 8: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onChannelCreationEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onChannelCreationEvent(*dataPackage); + case 8: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onChannelCreationEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onChannelCreationEvent(*dataPackage); + } + break; } - break; - } - case 9: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onChannelUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onChannelUpdateEvent(*dataPackage); + case 9: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onChannelUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onChannelUpdateEvent(*dataPackage); + } + break; } - break; - } - case 10: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onChannelDeletionEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onChannelDeletionEvent(*dataPackage); + case 10: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onChannelDeletionEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onChannelDeletionEvent(*dataPackage); + } + break; } - break; - } - case 11: { - if (discord_core_client::getInstance()->eventManager.onChannelPinsUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onChannelPinsUpdateEvent(*dataPackage); + case 11: { + if (discord_core_client::getInstance()->eventManager.onChannelPinsUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onChannelPinsUpdateEvent(*dataPackage); + } + break; } - break; - } - case 12: { - if (discord_core_client::getInstance()->eventManager.onThreadCreationEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onThreadCreationEvent(*dataPackage); + case 12: { + if (discord_core_client::getInstance()->eventManager.onThreadCreationEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onThreadCreationEvent(*dataPackage); + } + break; } - break; - } - case 13: { - if (discord_core_client::getInstance()->eventManager.onThreadUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onThreadUpdateEvent(*dataPackage); + case 13: { + if (discord_core_client::getInstance()->eventManager.onThreadUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onThreadUpdateEvent(*dataPackage); + } + break; } - break; - } - case 14: { - if (discord_core_client::getInstance()->eventManager.onThreadDeletionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onThreadDeletionEvent(*dataPackage); + case 14: { + if (discord_core_client::getInstance()->eventManager.onThreadDeletionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onThreadDeletionEvent(*dataPackage); + } + break; } - break; - } - case 15: { - if (discord_core_client::getInstance()->eventManager.onThreadListSyncEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onThreadListSyncEvent(*dataPackage); + case 15: { + if (discord_core_client::getInstance()->eventManager.onThreadListSyncEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onThreadListSyncEvent(*dataPackage); + } + break; } - break; - } - case 16: { - if (discord_core_client::getInstance()->eventManager.onThreadMemberUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onThreadMemberUpdateEvent(*dataPackage); + case 16: { + if (discord_core_client::getInstance()->eventManager.onThreadMemberUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onThreadMemberUpdateEvent(*dataPackage); + } + break; } - break; - } - case 17: { - if (discord_core_client::getInstance()->eventManager.onThreadMembersUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onThreadMembersUpdateEvent(*dataPackage); + case 17: { + if (discord_core_client::getInstance()->eventManager.onThreadMembersUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onThreadMembersUpdateEvent(*dataPackage); + } + break; } - break; - } - case 18: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onGuildCreationEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onGuildCreationEvent(*dataPackage); + case 18: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onGuildCreationEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onGuildCreationEvent(*dataPackage); + } + break; } - break; - } - case 19: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onGuildUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onGuildUpdateEvent(*dataPackage); + case 19: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onGuildUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onGuildUpdateEvent(*dataPackage); + } + break; } - break; - } - case 20: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onGuildDeletionEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onGuildDeletionEvent(*dataPackage); + case 20: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onGuildDeletionEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onGuildDeletionEvent(*dataPackage); + } + break; } - break; - } - case 21: { - if (discord_core_client::getInstance()->eventManager.onGuildBanAddEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildBanAddEvent(*dataPackage); + case 21: { + if (discord_core_client::getInstance()->eventManager.onGuildBanAddEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildBanAddEvent(*dataPackage); + } + break; } - break; - } - case 22: { - if (discord_core_client::getInstance()->eventManager.onGuildBanRemoveEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildBanRemoveEvent(*dataPackage); + case 22: { + if (discord_core_client::getInstance()->eventManager.onGuildBanRemoveEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildBanRemoveEvent(*dataPackage); + } + break; } - break; - } - case 23: { - if (discord_core_client::getInstance()->eventManager.onGuildEmojisUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildEmojisUpdateEvent(*dataPackage); + case 23: { + if (discord_core_client::getInstance()->eventManager.onGuildEmojisUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildEmojisUpdateEvent(*dataPackage); + } + break; } - break; - } - case 24: { - if (discord_core_client::getInstance()->eventManager.onGuildStickersUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildStickersUpdateEvent(*dataPackage); + case 24: { + if (discord_core_client::getInstance()->eventManager.onGuildStickersUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildStickersUpdateEvent(*dataPackage); + } + break; } - break; - } - case 25: { - if (discord_core_client::getInstance()->eventManager.onGuildIntegrationsUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildIntegrationsUpdateEvent(*dataPackage); + case 25: { + if (discord_core_client::getInstance()->eventManager.onGuildIntegrationsUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildIntegrationsUpdateEvent(*dataPackage); + } + break; } - break; - } - case 26: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onGuildMemberAddEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onGuildMemberAddEvent(*dataPackage); + case 26: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onGuildMemberAddEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onGuildMemberAddEvent(*dataPackage); + } + break; } - break; - } - case 27: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onGuildMemberRemoveEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onGuildMemberRemoveEvent(*dataPackage); + case 27: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onGuildMemberRemoveEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onGuildMemberRemoveEvent(*dataPackage); + } + break; } - break; - } - case 28: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onGuildMemberUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onGuildMemberUpdateEvent(*dataPackage); + case 28: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onGuildMemberUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onGuildMemberUpdateEvent(*dataPackage); + } + break; } - break; - } - case 29: { - if (discord_core_client::getInstance()->eventManager.onGuildMembersChunkEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildMembersChunkEvent(*dataPackage); + case 29: { + if (discord_core_client::getInstance()->eventManager.onGuildMembersChunkEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildMembersChunkEvent(*dataPackage); + } + break; } - break; - } - case 30: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onRoleCreationEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onRoleCreationEvent(*dataPackage); + case 30: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onRoleCreationEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onRoleCreationEvent(*dataPackage); + } + break; } - break; - } - case 31: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onRoleUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onRoleUpdateEvent(*dataPackage); + case 31: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onRoleUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onRoleUpdateEvent(*dataPackage); + } + break; } - break; - } - case 32: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onRoleDeletionEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onRoleDeletionEvent(*dataPackage); + case 32: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onRoleDeletionEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onRoleDeletionEvent(*dataPackage); + } + break; } - break; - } - case 33: { - if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventCreationEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildScheduledEventCreationEvent(*dataPackage); + case 33: { + if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventCreationEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, + dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildScheduledEventCreationEvent(*dataPackage); + } + break; } - break; - } - case 34: { - if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildScheduledEventUpdateEvent(*dataPackage); + case 34: { + if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildScheduledEventUpdateEvent(*dataPackage); + } + break; } - break; - } - case 35: { - if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventDeletionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildScheduledEventDeletionEvent(*dataPackage); + case 35: { + if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventDeletionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, + dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildScheduledEventDeletionEvent(*dataPackage); + } + break; } - break; - } - case 36: { - if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserAddEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserAddEvent(*dataPackage); + case 36: { + if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserAddEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, + dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserAddEvent(*dataPackage); + } + break; } - break; - } - case 37: { - if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserRemoveEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, - dataNew) }; - discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserRemoveEvent(*dataPackage); + case 37: { + if (discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserRemoveEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, + dataNew) }; + discord_core_client::getInstance()->eventManager.onGuildScheduledEventUserRemoveEvent(*dataPackage); + } + break; } - break; - } - case 38: { - if (discord_core_client::getInstance()->eventManager.onIntegrationCreationEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onIntegrationCreationEvent(*dataPackage); + case 38: { + if (discord_core_client::getInstance()->eventManager.onIntegrationCreationEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onIntegrationCreationEvent(*dataPackage); + } + break; } - break; - } - case 39: { - if (discord_core_client::getInstance()->eventManager.onIntegrationUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onIntegrationUpdateEvent(*dataPackage); + case 39: { + if (discord_core_client::getInstance()->eventManager.onIntegrationUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onIntegrationUpdateEvent(*dataPackage); + } + break; } - break; - } - case 40: { - if (discord_core_client::getInstance()->eventManager.onIntegrationDeletionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onIntegrationDeletionEvent(*dataPackage); + case 40: { + if (discord_core_client::getInstance()->eventManager.onIntegrationDeletionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onIntegrationDeletionEvent(*dataPackage); + } + break; } - break; - } - case 41: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onInteractionCreationEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onInteractionCreationEvent(*dataPackage); + case 41: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onInteractionCreationEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onInteractionCreationEvent(*dataPackage); + } + break; } - break; - } - case 42: { - if (discord_core_client::getInstance()->eventManager.onInviteCreationEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onInviteCreationEvent(*dataPackage); + case 42: { + if (discord_core_client::getInstance()->eventManager.onInviteCreationEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onInviteCreationEvent(*dataPackage); + } + break; } - break; - } - case 43: { - if (discord_core_client::getInstance()->eventManager.onInviteDeletionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onInviteDeletionEvent(*dataPackage); + case 43: { + if (discord_core_client::getInstance()->eventManager.onInviteDeletionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onInviteDeletionEvent(*dataPackage); + } + break; } - break; - } - case 44: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onMessageCreationEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onMessageCreationEvent(*dataPackage); + case 44: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onMessageCreationEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onMessageCreationEvent(*dataPackage); + } + break; } - break; - } - case 45: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onMessageUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onMessageUpdateEvent(*dataPackage); + case 45: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onMessageUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onMessageUpdateEvent(*dataPackage); + } + break; } - break; - } - case 46: { - if (discord_core_client::getInstance()->eventManager.onMessageDeletionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onMessageDeletionEvent(*dataPackage); + case 46: { + if (discord_core_client::getInstance()->eventManager.onMessageDeletionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onMessageDeletionEvent(*dataPackage); + } + break; } - break; - } - case 47: { - if (discord_core_client::getInstance()->eventManager.onMessageDeleteBulkEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onMessageDeleteBulkEvent(*dataPackage); + case 47: { + if (discord_core_client::getInstance()->eventManager.onMessageDeleteBulkEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onMessageDeleteBulkEvent(*dataPackage); + } + break; } - break; - } - case 48: { - if (discord_core_client::getInstance()->eventManager.onReactionAddEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onReactionAddEvent(*dataPackage); + case 48: { + if (discord_core_client::getInstance()->eventManager.onReactionAddEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onReactionAddEvent(*dataPackage); + } + break; } - break; - } - case 49: { - if (discord_core_client::getInstance()->eventManager.onReactionRemoveEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onReactionRemoveEvent(*dataPackage); + case 49: { + if (discord_core_client::getInstance()->eventManager.onReactionRemoveEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onReactionRemoveEvent(*dataPackage); + } + break; } - break; - } - case 50: { - if (discord_core_client::getInstance()->eventManager.onReactionRemoveAllEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onReactionRemoveAllEvent(*dataPackage); + case 50: { + if (discord_core_client::getInstance()->eventManager.onReactionRemoveAllEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onReactionRemoveAllEvent(*dataPackage); + } + break; } - break; - } - case 51: { - if (discord_core_client::getInstance()->eventManager.onReactionRemoveEmojiEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onReactionRemoveEmojiEvent(*dataPackage); + case 51: { + if (discord_core_client::getInstance()->eventManager.onReactionRemoveEmojiEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onReactionRemoveEmojiEvent(*dataPackage); + } + break; } - break; - } - case 52: { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - if (discord_core_client::getInstance()->eventManager.onPresenceUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onPresenceUpdateEvent(*dataPackage); + case 52: { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + if (discord_core_client::getInstance()->eventManager.onPresenceUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onPresenceUpdateEvent(*dataPackage); + } + break; } - break; - } - case 53: { - if (discord_core_client::getInstance()->eventManager.onStageInstanceCreationEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onStageInstanceCreationEvent(*dataPackage); + case 53: { + if (discord_core_client::getInstance()->eventManager.onStageInstanceCreationEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onStageInstanceCreationEvent(*dataPackage); + } + break; } - break; - } - case 54: { - if (discord_core_client::getInstance()->eventManager.onStageInstanceUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onStageInstanceUpdateEvent(*dataPackage); + case 54: { + if (discord_core_client::getInstance()->eventManager.onStageInstanceUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onStageInstanceUpdateEvent(*dataPackage); + } + break; } - break; - } - case 55: { - if (discord_core_client::getInstance()->eventManager.onStageInstanceDeletionEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onStageInstanceDeletionEvent(*dataPackage); + case 55: { + if (discord_core_client::getInstance()->eventManager.onStageInstanceDeletionEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onStageInstanceDeletionEvent(*dataPackage); + } + break; } - break; - } - case 56: { - if (discord_core_client::getInstance()->eventManager.onTypingStartEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onTypingStartEvent(*dataPackage); + case 56: { + if (discord_core_client::getInstance()->eventManager.onTypingStartEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onTypingStartEvent(*dataPackage); + } + break; } - break; - } - case 57: { - if (discord_core_client::getInstance()->eventManager.onUserUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onUserUpdateEvent(*dataPackage); + case 57: { + if (discord_core_client::getInstance()->eventManager.onUserUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onUserUpdateEvent(*dataPackage); + } + break; } - break; - } - case 58: { - unique_ptr dataPackage{ makeUnique(parser, dataNew, this) }; - if (discord_core_client::getInstance()->eventManager.onVoiceStateUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onVoiceStateUpdateEvent(*dataPackage); + case 58: { + unique_ptr dataPackage{ makeUnique(parser, dataNew, this) }; + if (discord_core_client::getInstance()->eventManager.onVoiceStateUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onVoiceStateUpdateEvent(*dataPackage); + } + break; } - break; - } - case 59: { - unique_ptr dataPackage{ makeUnique(parser, dataNew, this) }; - if (discord_core_client::getInstance()->eventManager.onVoiceServerUpdateEvent.functions.size() > 0) { - discord_core_client::getInstance()->eventManager.onVoiceServerUpdateEvent(*dataPackage); + case 59: { + unique_ptr dataPackage{ makeUnique(parser, dataNew, this) }; + if (discord_core_client::getInstance()->eventManager.onVoiceServerUpdateEvent.functions.size() > 0) { + discord_core_client::getInstance()->eventManager.onVoiceServerUpdateEvent(*dataPackage); + } + break; } - break; - } - case 60: { - if (discord_core_client::getInstance()->eventManager.onWebhookUpdateEvent.functions.size() > 0) { - unique_ptr dataPackage{ makeUnique(parser, dataNew) }; - discord_core_client::getInstance()->eventManager.onWebhookUpdateEvent(*dataPackage); + case 60: { + if (discord_core_client::getInstance()->eventManager.onWebhookUpdateEvent.functions.size() > 0) { + unique_ptr dataPackage{ makeUnique(parser, dataNew) }; + discord_core_client::getInstance()->eventManager.onWebhookUpdateEvent(*dataPackage); + } + break; } - break; } } } @@ -951,7 +966,7 @@ namespace discord_core_api { } case websocket_op_codes::Invalid_Session: { websocket_message_data data{}; - parser.parseJson(data, dataNew); + parser.parseJson(data, dataNew); if (auto result = parser.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -975,7 +990,7 @@ namespace discord_core_api { } case websocket_op_codes::hello: { websocket_message_data data{}; - parser.parseJson(data, dataNew); + parser.parseJson(data, dataNew); if (auto result = parser.getErrors(); result.size() > 0) { for (auto& valueNew: result) { message_printer::printError(valueNew.reportError()); @@ -1178,6 +1193,7 @@ namespace discord_core_api { } } - base_socket_agent::~base_socket_agent(){} + base_socket_agent::~base_socket_agent() { + } }// namespace discord_core_internal }// namespace discord_core_api diff --git a/Source/YouTubeAPI.cpp b/Source/YouTubeAPI.cpp index 117fa80a7..b1c28c86e 100644 --- a/Source/YouTubeAPI.cpp +++ b/Source/YouTubeAPI.cpp @@ -197,7 +197,7 @@ namespace discord_core_api { jsonifier::string stringSequence = ";