{"id":13409845,"url":"https://github.com/RealTimeChris/DiscordCoreAPI","last_synced_at":"2025-03-14T15:30:53.016Z","repository":{"id":37234004,"uuid":"379578416","full_name":"RealTimeChris/DiscordCoreAPI","owner":"RealTimeChris","description":"A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.","archived":false,"fork":false,"pushed_at":"2024-10-20T22:24:05.000Z","size":14525,"stargazers_count":153,"open_issues_count":2,"forks_count":17,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-21T04:16:51.473Z","etag":null,"topics":["bot","bot-library","coroutine","cpp","discord","discord-api","discord-bot","discord-core","discord-server","discordcoreapi","rest-api","voice-support","websocket"],"latest_commit_sha":null,"homepage":"https://discordcoreapi.com","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RealTimeChris.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.paypal.com/donate/?hosted_button_id=Z6RURQ8UCLQHY"]}},"created_at":"2021-06-23T11:22:52.000Z","updated_at":"2024-10-15T21:43:25.000Z","dependencies_parsed_at":"2024-01-21T09:48:26.804Z","dependency_job_id":"0d681091-f9e2-4e2d-8394-c01e227bbdd6","html_url":"https://github.com/RealTimeChris/DiscordCoreAPI","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FDiscordCoreAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FDiscordCoreAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FDiscordCoreAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FDiscordCoreAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RealTimeChris","download_url":"https://codeload.github.com/RealTimeChris/DiscordCoreAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515567,"owners_count":20303258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","bot-library","coroutine","cpp","discord","discord-api","discord-bot","discord-core","discord-server","discordcoreapi","rest-api","voice-support","websocket"],"created_at":"2024-07-30T20:01:03.688Z","updated_at":"2025-03-14T15:30:52.998Z","avatar_url":"https://github.com/RealTimeChris.png","language":"C++","readme":"# DiscordCoreAPI\n[![Codacy Badge](https://img.shields.io/codacy/grade/1e5ae970aed34d0b96249cdfd02099cf?color=lightblue\u0026label=Code%20Quality\u0026style=plastic)](https://www.codacy.com/gh/RealTimeChris/DiscordCoreAPI/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=RealTimeChris/DiscordCoreAPI\u0026amp;utm_campaign=Badge_Grade)\n[![Discord](https://img.shields.io/discord/931640556814237706?color=red\u0026label=Discord%20Server\u0026style=plastic)](https://discord.gg/c33GH5BUe8)\n![Commit Activity](https://img.shields.io/github/commit-activity/y/realtimechris/discordcoreapi?color=green\u0026label=Commits\u0026style=plastic)\n![Lines of Code](https://tokei.rs/b1/github/RealTimeChris/DiscordCoreAPI-Code-Only?color=light-blue\u0026label=Lines%20Of%20Code%20\u0026style=plastic)\n\nHello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in C++, that leverages custom asynchronous [CoRoutines](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/CoRoutine.hpp), as well as a home-brew set of [Https](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/Utilities/HttpsClient.hpp#L241),\n[WebSocket](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/Utilities/WebSocketClient.hpp#L175), and [Datagram](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/VoiceConnection.hpp#L272) 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.\n\n\u003cp align=\"center\"\u003e\u003ca href=\"http://discordcoreapi.com\" target=\"_blank\"\u003e\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/TheLogo.png?raw=true\" \nalt=\"DiscordCoreAPI WebSite\" width=\"500\"/\u003e\u003c/p\u003e\n\n## Compiler Support\n![MSVC_20922](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC-Windows.yml?style=plastic\u0026logo=microsoft\u0026logoColor=green\u0026label=MSVC_2022\u0026labelColor=pewter\u0026color=blue)\n![CLANG_18](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG-Ubuntu.yml?style=plastic\u0026logo=linux\u0026logoColor=green\u0026label=CLANG_18\u0026labelColor=pewter\u0026color=blue)\n![GCC_13](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC-MacOS.yml?style=plastic\u0026logo=apple\u0026logoColor=green\u0026label=GCC_13\u0026labelColor=pewter\u0026color=blue)\n\n## Operating System Support\n![Windows](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/MSVC-Windows.yml?style=plastic\u0026logo=microsoft\u0026logoColor=green\u0026label=Windows\u0026labelColor=pewter\u0026color=blue)\n![Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG-Ubuntu.yml?style=plastic\u0026logo=linux\u0026logoColor=green\u0026label=Linux\u0026labelColor=pewter\u0026color=blue)\n![Mac](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/GCC-MacOS.yml?style=plastic\u0026logo=apple\u0026logoColor=green\u0026label=MacOS\u0026labelColor=pewter\u0026color=blue)\n\n# Documentation/Examples\n[Documentation/Examples](https://discordcoreapi.com/documentation_examples.html)\n\n# Discord Server\n[This is a link to the Discord server!](https://discord.gg/c33GH5BUe8)\n\n# Bot Template\n[A template for utilizing this library.](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI)\n\n# Features   \n\n## Convert Snowflakes Into Data\n----\n- Using the `discord_core_api::snowflake::toEntity()` function of the `snowflake` class allows for converting the entity's id directly into the data structure represented by it.\n- \n```cpp\ndiscord_core_api::snowflake someChannelId{};\ndiscord_core_api::channel_data newChannel = someChannelId.toEntity\u003cdiscord_core_api::channel_data\u003e();\nstd::cout \u003c\u003c \"CHANNEL NAME: \" + newChannel.name \u003c\u003c std::endl;\n```\n\n## Performant\n----\n- Thanks to utilizing [Erlang Text Format](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/Utilities/Etf.hpp) for websocket transfer, and a pool of [kept-alive HTTPS connections](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/Utilities/HttpsClient.hpp#L213) - this library offers the snappiest responses to your interactions and user input.\n\n## Audio-Bridge\n----\n- Connect multiple voice-channels to one-another using the `StreamInfo` member of the `VoiceConnectInitData` structure, with the `VoiceConnection` class.\n\n## CPU Efficient   \n----\n- It only uses about 0.1% of an Intel i7 9750h to stream audio in high quality (Opus 48Khz 16-bit Stereo) to a single server.   \n\n## Entire Discord API Covered   \n----\n- All of the Discord API endpoints are covered in this library, including voice communication.\n\n## Concurrent Discord API Access   \n----\n- As a result of using [custom asynchronous coroutines](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/CoRoutine.hpp) along with a [thread pool](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Include/discordcoreapi/Utilities/CoRoutineThreadPool.hpp#L70), this library has the ability to make fully    asynchronous/concurrent requests to the Discord API.    \n\n## Advanced Rate-Limiting System\n----\n- Guarantees that the order in which HTTPS requests are executed is the same that they were submitted in - despite being launched across different threads, while never infracting on any of the Discord API's rate-limits and while running concurrently across all of the endpoints.\n\u003cp align=\"left\"\u003e\n\t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/Rate-Limit.png?raw=true\" width=\"700\"\u003e\n\u003c/p\u003e\n\n## Slash Commands and Buttons\n----\n\u003cp align=\"left\"\u003e\n \t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/Slash-Commands and Buttons.png?raw=true\"  width=\"700\"\u003e   \n\u003c/p\u003e\n\n## Select Menus\n----\n\u003cp align=\"left\"\u003e\n \t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/Select-Menu-01.png?raw=true\"  width=\"700\"\u003e \n \t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/Select-Menu-02.png?raw=true\"  width=\"700\"\u003e   \n\u003c/p\u003e\n   \n\n## User Commands   \n----\n\u003cp align=\"left\"\u003e\n \t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/User-Command.png?raw=true\"  width=\"700\"\u003e   \n\u003c/p\u003e\n   \n\n## Message Commands   \n----\n\u003cp align=\"left\"\u003e\n \t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/Message-Command.png?raw=true\"  width=\"700\"\u003e   \n\u003c/p\u003e\n\n   \n## Modal Text Inputs\n----\n\u003cp align=\"left\"\u003e\n \t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/Modal-01.png?raw=true\"  width=\"700\"\u003e   \n\t\u003cimg src=\"https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Documentation/Images/Modal-02.png?raw=true\"  width=\"700\"\u003e   \n\u003c/p\u003e\n\n   \n## A Unified \"Input-Event\" System\n----\n- User interactions (Application Commands, Message Commands, User Commands) are accepted via the `event_manager::onInputEventCreation` event.\n- They can all be responded to using the `input_events::respondToInputEventAsync()` function.\n- Alternatively you can implement your own input-event handling by using the raw `event_manager::onInteractionCreation` or `event_manager::onMessageCreation` events.\n```cpp\nEmbedData newEmbed{};\nnewEmbed.setAuthor(args.eventData.getUserName(), args.eventData.getAvatarURL());\nnewEmbed.setDescription(\"------\\\\n__**Sorry, but there's already something play\ning!**__\\\\n------\");\nnewEmbed.setTimeStamp(getTimeAndDate());\nnewEmbed.setTitle(\"__**Playing Issue:**__\");\nnewEmbed.setColor(discordGuild.data.borderColor);\nRespondToInputEventData dataPackage{ args.eventData };\ndataPackage.addMessageEmbed(newEmbed);\ndataPackage.setResponseType(InputEventResponseType::Ephemeral_Interaction_Response);\nInputEventData newEvent = input_events::respondToInputEvent(dataPackage);\ninput_events::deleteInputEventResponseAsync(newEvent, 20000).get();\n```\n\n# Build Instructions (Full-Vcpkg)\n----\n- [Install vcpkg](https://vcpkg.io/en/getting-started.html), if need be.\n- Make sure to run `vcpkg integrate install`.\n- Enter within a terminal `vcpkg install discordcoreapi:x64-windows_OR_linux`.\n- Set up a console project in your IDE and make sure to set the C++ standard to C++20 or later - and include `discordcoreapi/Index.hpp`.\n- Build and run!\n\n# Dependencies\n----\n- [CMake](https://cmake.org/) (Version 3.20 or greater)\n- NOTE: I installed these using the [vcpkg](https://github.com/microsoft/vcpkg) installer.\n- [DiscordCoreAPI](https://github.com/RealTimeChris/DiscordCoreAPI) (.\\\\vcpkg install jsonifier:x64-windows_OR_linux)\n- [OpenSSL](https://github.com/openssl/openssl) (.\\\\vcpkg install openssl:x64-windows_OR_linux)\n- [Opus](https://github.com/xiph/opus) (.\\\\vcpkg install opus:x64-windows_OR_linux)\n- [Sodium](https://github.com/jedisct1/libsodium) (.\\\\vcpkg install libsodium:x64-windows_OR_linux)\n\n# Build Instructions (Non-Vcpkg) - The Library   \n----\n- Install the [dependencies](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/ReadMe.md#dependencies).   \n- Clone [this](https://github.com/RealTimeChris/DiscordCoreAPI) git repository into a folder.   \n- Set, in CMakeLists.txt, the `_VCPKG_ROOT_DIR`, or the `Opus_DIR`, `unofficial-sodium_DIR` paths to wherever each of the respective dependency files are located and they are as follows:     \n\t- Opus_DIR # Set this one to the folder location of the file \"OpusConfig.cmake\".   \n\t- unofficial-sodium_DIR # Set this one to the folder location of the file \"unofficial-sodiumConfig.cmake\".   \n\t- OPENSSL_ROOT_DIR # Set this one to the folder location of the include folder and library folders of OpenSSL.   \n- Open a terminal inside the git repo's folder.   \n- Run `cmake -S . --preset Linux_OR_Windows-Debug_OR_Release`.\n- Then run `cmake --build --preset Linux_OR_Windows-Debug_OR_Release`.   \n- Run within the same terminal and folder `cmake --install ./Build/Debug_OR_Release`.\n- The default installation paths are: Windows = \"ROOT_DRIVE:/Users/USERNAME/CMake/DiscordCoreAPI\", Linux = \"/home/USERNAME/CMake/DiscordCoreAPI\"\n\n# The CMAKE Package\n----\n- By running `cmake --install ./Build/Debug_OR_Release`, you will be given a cmake package, which can be used to build from this library, using other cmake projects.\n- It is used by setting `DiscordCoreAPI_DIR` to wherever the DiscordCoreAPIConfig.cmake file would have been installed on your system by having run the `cmake --install` command, and then using `find_package()` on `DiscordCoreAPI`.\n- When found, you will be granted the following cmake \"variables\"; `DiscordCoreAPI` - this is the library target which can be linked to from other targets in cmake, and on Windows; `$\u003cTARGET_RUNTIME_DLLS:DiscordCoreAPI-Bot\u003e` - which is a list of dll files to be copied into your executable's final location after building. As well as `RELEASE_PDB_FILE_PATH`, `DEBUG_PDB_FILE_PATH`, `RELEASE_PDB_FILE_NAME`, and `DEBUG_PDB_FILE_NAME`, which are full file/directory paths/filenames to the library's PDB files.\n- [Here](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI/blob/main/CMakeLists.txt) and [here](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI/blob/main/Executable/CMakeLists.txt) is an example of building an executable from this library with this method.\n\n# Build Instructions (Non-Vcpkg) - The Executable\n----\n- Download the [bot template](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI) or create your own with the same [imports](https://github.com/RealTimeChris/Bot-Template-For-DiscordCoreAPI/blob/main/CMakeLists.txt#L49), and set within it either the `VCPKG_ROOT_DIR`, or the `CMAKE_CONFIG_FILE_DIR`, `Opus_DIR`, and `unofficial-sodium_DIR` paths to wherever each of the respective dependency files are located and they are as follows:   \n\t- CMAKE_CONFIG_FILE_DIR # Set this one to the folder location of the DiscordCoreAPIConfig.cmake generated while running CMake --install.  \n\t- Opus_DIR # Set this one to the folder location of the file \"OpusConfig.cmake\".   \n\t- unofficial-sodium_DIR # Set this one to the folder location of the file \"unofficial-sodiumConfig.cmake\".   \n\t- OPENSSL_ROOT_DIR # Set this one to the folder location of the include folder and library folders of OpenSSL.   \n- Set up a main.cpp like [this one](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI/blob/main/main.cpp), including the header `discordcoreapi/Index.hpp`.\n- Run in a terminal from within the same folder as the top-level CMakeLists.txt, `cmake -S . --preset Linux_OR_Windows-Debug_OR_Release`.\n- Then run `cmake --build --preset Linux_OR_Windows-Debug_OR_Release`.\n- Run within the same terminal and folder `cmake --install ./Build/Debug_OR_Release`.\n- The default installation paths are: Windows = \"ROOT_DRIVE:/Users/USERNAME/CMake/Bot-Template-For-DiscordCoreAPI\", Linux = \"/home/USERNAME/CMake/Bot-Template-For-DiscordCoreAPI\"\n\t\n# Roadmap\nI am currently working on getting this thing to be used by people like you! So, if you have any suggestions for the library that would make it more usable - don't hesitate to let me know! I can be\neasily found on the Discord server that is linked to above! Cheers and thanks for your time.\n","funding_links":["https://www.paypal.com/donate/?hosted_button_id=Z6RURQ8UCLQHY"],"categories":["API Libraries","Libraries"],"sub_categories":["C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRealTimeChris%2FDiscordCoreAPI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRealTimeChris%2FDiscordCoreAPI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRealTimeChris%2FDiscordCoreAPI/lists"}