Skip to content

Commit d807a1a

Browse files
committed
DiscordCoreAPI v1.60 Release
Hey everyone just a new release here, with the following changes being primary: -Fixed an issue with the SongAPI classes' stop method. -Updated the move assignment operator of the UniquePtr class. -Updated the VoiceConnection and SongAPI's logic to improve simplicity. -Updated the License. -Refactored the namespaces for increased simplicity. -Fixed an issue mentioned here: #32
1 parent f3e63b7 commit d807a1a

File tree

279 files changed

+10527
-10918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+10527
-10918
lines changed

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,5 @@ project(
7070
)
7171
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/CMake;")
7272
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}")
73-
set(CMAKE_CXX_STANDARD 23)
7473

7574
add_subdirectory(Library)

Documentation/Doxygen/Documentation-Examples/999-ReadMe.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
![Commit Activity](https://img.shields.io/github/commit-activity/y/realtimechris/discordcoreapi?color=green&label=Commits&style=plastic)
55
![Lines of code](https://img.shields.io/tokei/lines/github/realtimechris/discordcoreapi?&style=plastic&label=Lines%20of%20Code)
66

7-
Hello, 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/Source/Https.cpp#L369),
8-
[WebSocket](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Source/WebSocketEntities.cpp#L414), and [Datagram](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Source/VoiceConnection.cpp#L285) 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.
7+
Hello, 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/Source/Https.cpp#L375),
8+
[WebSocket](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Source/WebSocketEntities.cpp#L441), and [Datagram](https://github.com/RealTimeChris/DiscordCoreAPI/blob/main/Source/VoiceConnection.cpp#L277) 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.
99

1010
![imageDiscordCoreAPI](./TheLogo.png "A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.")
1111

@@ -15,7 +15,7 @@ Hello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in
1515
![CLANG_17](https://img.shields.io/github/actions/workflow/status/RealTimeChris/DiscordCoreAPI/CLANG_17.yml?color=00ff90&label=CLANG_17)
1616

1717
# Documentation/Examples
18-
[Documentation/Examples](https://discordcoreapi.com/d8/dad/a08642.html)
18+
[Documentation/Examples](https://discordcoreapi.com/d8/d3d/a08569.html)
1919

2020
# Discord Server
2121
[This is a link to the Discord server!](https://discord.gg/adgMqeBuhP)
@@ -26,10 +26,10 @@ Hello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in
2626
# Features
2727

2828
## Performant
29-
- 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/Https.hpp#L141) - this library offers the snappiest responses to your interactions and user input.
29+
- 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/Https.hpp#L143) - this library offers the snappiest responses to your interactions and user input.
3030

3131
## Audio-Bridge
32-
- Connect multiple voice-channels to one-another using the `DiscordCoreAPI::StreamInfo` member of the `DiscordCoreAPI::VoiceConnectInitData` structure, with the `DiscordCoreAPI::VoiceConnection` class.
32+
- Connect multiple voice-channels to one-another using the `StreamInfo` member of the `VoiceConnectInitData` structure, with the `VoiceConnection` class.
3333

3434
## CPU Efficient
3535
- 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.
@@ -38,7 +38,7 @@ Hello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in
3838
- All of the Discord API endpoints are covered in this library, including voice communication.
3939

4040
## Concurrent Discord API Access
41-
- 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/ThreadPool.hpp#L146), this library has the ability to make fully asynchronous/concurrent requests to the Discord API.
41+
- 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/ThreadPool.hpp#L146), this library has the ability to make fully asynchronous/concurrent requests to the Discord API.
4242

4343
## Advanced Rate-Limiting System
4444
- 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.
@@ -76,21 +76,21 @@ Hello, and welcome to DiscordCoreAPI! This is a Discord bot library, written in
7676
</p>
7777

7878
## A Unified "Input-Event" System
79-
- User interactions (Application Commands, Message Commands, User Commands) are accepted via the `DiscordCoreAPI::EventManager::onInputEventCreation` event.
80-
- They can all be responded to using the `DiscordCoreAPI::InputEvents::respondToInputEventAsync()` function.
81-
- Alternatively you can implement your own input-event handling by using the raw `DiscordCoreAPI::EventManager::onInteractionCreation` or `DiscordCoreAPI::EventManager::onMessageCreation` events.
79+
- User interactions (Application Commands, Message Commands, User Commands) are accepted via the `EventManager::onInputEventCreation` event.
80+
- They can all be responded to using the `InputEvents::respondToInputEventAsync()` function.
81+
- Alternatively you can implement your own input-event handling by using the raw `EventManager::onInteractionCreation` or `EventManager::onMessageCreation` events.
8282
```cpp
83-
DiscordCoreAPI::EmbedData newEmbed{};
83+
EmbedData newEmbed{};
8484
newEmbed.setAuthor(args.eventData.getUserName(), args.eventData.getAvatarURL());
8585
newEmbed.setDescription("------\\n__**Sorry, but there's already something playing!**__\\n------");
8686
newEmbed.setTimeStamp(getTimeAndDate());
8787
newEmbed.setTitle("__**Playing Issue:**__");
8888
newEmbed.setColor(discordGuild.data.borderColor);
89-
DiscordCoreAPI::RespondToInputEventData dataPackage{ args.eventData };
89+
RespondToInputEventData dataPackage{ args.eventData };
9090
dataPackage.addMessageEmbed(newEmbed);
91-
dataPackage.setResponseType(DiscordCoreAPI::InputEventResponseType::Ephemeral_Interaction_Response);
92-
DiscordCoreAPI::InputEventData newEvent = DiscordCoreAPI::InputEvents::respondToInputEvent(dataPackage);
93-
DiscordCoreAPI::InputEvents::deleteInputEventResponseAsync(newEvent, 20000).get();
91+
dataPackage.setResponseType(InputEventResponseType::Ephemeral_Interaction_Response);
92+
InputEventData newEvent = InputEvents::respondToInputEvent(dataPackage);
93+
InputEvents::deleteInputEventResponseAsync(newEvent, 20000).get();
9494
```
9595
9696
# Supported Platforms
@@ -127,7 +127,7 @@ DiscordCoreAPI::InputEvents::deleteInputEventResponseAsync(newEvent, 20000).get(
127127
# The CMAKE Package
128128
- 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.
129129
- 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`.
130-
- When found, you will be granted the following cmake "variables"; `DiscordCoreAPI::DiscordCoreAPI` - this is the library target which can be linked to from other targets in cmake, and on Windows; `$<TARGET_RUNTIME_DLLS:DiscordCoreAPI-Bot>` - 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.
130+
- 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; `$<TARGET_RUNTIME_DLLS:DiscordCoreAPI-Bot>` - 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.
131131
- [Here](https://github.com/RealTimeChris/Bot-Template-for-DiscordCoreAPI/blob/main/CMakeLists.txt) is an example of building an executable from this library with this method.
132132
133133
# Build Instructions (Non-Vcpkg) - The Executable

Documentation/Doxygen/Documentation-Examples/Application-Command-Stuff/Batch Edit Guild Application Command Permissions.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Batch Editing Guild Application Command's Permissions {#batcheditguildcommandpermissions}
22
============
3-
- Execute the `DiscordCoreAPI::ApplicationCommands::batchEditGuildApplicationCommandPermissionsAsync()` function, while passing in a data structure of type `DiscordCoreAPI::BatchEditGuildApplicationCommandPermissionsData`, with a return value of type `auto` or `std::vector<DiscordCoreAPI::GuildApplicationCommandPermissionsData>`.
3+
- Execute the `ApplicationCommands::batchEditGuildApplicationCommandPermissionsAsync()` function, while passing in a data structure of type `BatchEditGuildApplicationCommandPermissionsData`, with a return value of type `auto` or `std::vector<GuildApplicationCommandPermissionsData>`.
44
- Call the function with `.get()` added to the end in order to wait for the results now.
55

66
```cpp
@@ -13,37 +13,37 @@ Batch Editing Guild Application Command's Permissions {#batcheditguildcommandper
1313

1414
namespace DiscordCoreAPI {
1515

16-
class Test : public DiscordCoreAPI::BaseFunction {
16+
class Test : public BaseFunction {
1717
public:
1818
Test() {
1919
commandName = "test";
2020
helpDescription = "Testing purposes!";
21-
DiscordCoreAPI::EmbedData msgEmbed;
21+
EmbedData msgEmbed;
2222
msgEmbed.setDescription("------\nSimply enter !test or /test!\n------");
2323
msgEmbed.setTitle("__**Test Usage:**__");
2424
msgEmbed.setTimeStamp(getTimeAndDate());
2525
msgEmbed.setColor("FeFeFe");
2626
helpEmbed = msgEmbed;
2727
}
2828

29-
DiscordCoreAPI::UniquePtr<DiscordCoreAPI::BaseFunction> create() {
30-
return DiscordCoreAPI::makeUnique<Test>();
29+
UniquePtr<BaseFunction> create() {
30+
return makeUnique<Test>();
3131
}
3232

33-
virtual void execute(DiscordCoreAPI::BaseFunctionArguments& args) {
34-
DiscordCoreAPI::InputEvents::deleteInputEventResponseAsync(args.eventData).get();
33+
virtual void execute(BaseFunctionArguments& args) {
34+
InputEvents::deleteInputEventResponseAsync(args.eventData).get();
3535

36-
DiscordCoreAPI::BatchEditGuildApplicationCommandPermissionsData dataPackage01;
37-
std::vector<DiscordCoreAPI::EditGuildApplicationCommandPermissionsData> dataPackage02 {
36+
BatchEditGuildApplicationCommandPermissionsData dataPackage01;
37+
std::vector<EditGuildApplicationCommandPermissionsData> dataPackage02 {
3838
{.permissions = {{.type = ApplicationCommandPermissionType::User, .permission = false, .id = "859853159115259905"}},
3939
.commandName = "selldrugs"}};
4040
dataPackage01.guildId = args.eventData.getGuildId();
4141
dataPackage01.permissions = dataPackage02;
4242

43-
auto returnVector = DiscordCoreAPI::ApplicationCommands::batchEditGuildApplicationCommandPermissionsAsync(dataPackage01).get();
43+
auto returnVector = ApplicationCommands::batchEditGuildApplicationCommandPermissionsAsync(dataPackage01).get();
4444

4545
for (auto value: returnVector) {
46-
cout << value.applicationId << endl;
46+
std::cout << value.applicationId << std::endl;
4747
}
4848
}
4949
};

Documentation/Doxygen/Documentation-Examples/Application-Command-Stuff/Bulk Overwrite Global Application Commands.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Bulk Overwriting Global Application Commands {#bulkoverwriteglobalcommands}
22
============
3-
- Execute the `DiscordCoreAPI::ApplicationCommands::bulkOverwriteGlobalApplicationCommandsAsync()` function, while passing in a data structure of type `DiscordCoreAPI::BulkOverwriteGlobalApplicationCommandsData`, with a return value of `auto` or `std::vector<DiscordCoreAPI::ApplicationCommand>`.
3+
- Execute the `ApplicationCommands::bulkOverwriteGlobalApplicationCommandsAsync()` function, while passing in a data structure of type `BulkOverwriteGlobalApplicationCommandsData`, with a return value of `auto` or `std::vector<ApplicationCommand>`.
44
- Call the function with `.get()` added to the end in order to wait for the results now.
55

66
```cpp
@@ -13,44 +13,44 @@ Bulk Overwriting Global Application Commands {#bulkoverwriteglobalcommands}
1313

1414
namespace DiscordCoreAPI {
1515

16-
class Test : public DiscordCoreAPI::BaseFunction {
16+
class Test : public BaseFunction {
1717
public:
1818
Test() {
1919
commandName = "test";
2020
helpDescription = "Testing purposes!";
21-
DiscordCoreAPI::EmbedData msgEmbed;
21+
EmbedData msgEmbed;
2222
msgEmbed.setDescription("------\nSimply enter !test or /test!\n------");
2323
msgEmbed.setTitle("__**Test Usage:**__");
2424
msgEmbed.setTimeStamp(getTimeAndDate());
2525
msgEmbed.setColor("FeFeFe");
2626
helpEmbed = msgEmbed;
2727
}
2828

29-
DiscordCoreAPI::UniquePtr<DiscordCoreAPI::BaseFunction> create() {
30-
return DiscordCoreAPI::makeUnique<Test>();
29+
UniquePtr<BaseFunction> create() {
30+
return makeUnique<Test>();
3131
}
3232

33-
virtual void execute(DiscordCoreAPI::BaseFunctionArguments& args) {
34-
vector<DiscordCoreAPI::CreateGlobalApplicationCommandData> newVector;
35-
DiscordCoreAPI::CreateGlobalApplicationCommandData createSellDrugsCommandData;
33+
virtual void execute(BaseFunctionArguments& args) {
34+
vector<CreateGlobalApplicationCommandData> newVector;
35+
CreateGlobalApplicationCommandData createSellDrugsCommandData;
3636
createSellDrugsCommandData.description = "Sell drugs in exchange for some currency!";
3737
createSellDrugsCommandData.name = "selldrugs";
38-
createSellDrugsCommandData.type = DiscordCoreAPI::ApplicationCommandType::Chat_Input;
38+
createSellDrugsCommandData.type = ApplicationCommandType::Chat_Input;
3939
newVector.emplace_back(createSellDrugsCommandData);
4040

41-
DiscordCoreAPI::CreateGlobalApplicationCommandData registerSlashCommandsCommandData;
41+
CreateGlobalApplicationCommandData registerSlashCommandsCommandData;
4242
registerSlashCommandsCommandData.description = "Register the programmatically designated slash commands.";
4343
registerSlashCommandsCommandData.name = "registerslashcommands";
4444
registerSlashCommandsCommandData.type = ApplicationCommandType::Chat_Input;
4545
newVector.emplace_back(registerSlashCommandsCommandData);
4646

47-
DiscordCoreAPI::BulkOverwriteGlobalApplicationCommandsData dataPackage;
47+
BulkOverwriteGlobalApplicationCommandsData dataPackage;
4848
dataPackage.data = newVector;
4949

50-
auto returnValue = DiscordCoreAPI::ApplicationCommands::bulkOverwriteGlobalApplicationCommandsAsync(dataPackage).get();
50+
auto returnValue = ApplicationCommands::bulkOverwriteGlobalApplicationCommandsAsync(dataPackage).get();
5151

5252
for (auto value: returnValue) {
53-
cout << "Command Name: " << value.name << endl;
53+
std::cout << "Command Name: " << value.name << std::endl;
5454
}
5555
}
5656
};

Documentation/Doxygen/Documentation-Examples/Application-Command-Stuff/Bulk Overwrite Guild Application Commands.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Bulk Overwriting Guild Application Commands {#bulkoverwriteguildcommands}
22
============
3-
- Execute the `DiscordCoreAPI::ApplicationCommands::bulkOverwriteGuildApplicationCommandsAsync()` function and execute it, while passing in a data structure of type `DiscordCoreAPI::BulkOverwriteGuildApplicationCommandsData`, with a return value of `auto` or `std::vector<DiscordCoreAPI::ApplicationCommand>`.
3+
- Execute the `ApplicationCommands::bulkOverwriteGuildApplicationCommandsAsync()` function and execute it, while passing in a data structure of type `BulkOverwriteGuildApplicationCommandsData`, with a return value of `auto` or `std::vector<ApplicationCommand>`.
44
- Call the function with `.get()` added to the end in order to wait for the results now.
55

66
```cpp
@@ -13,45 +13,45 @@ Bulk Overwriting Guild Application Commands {#bulkoverwriteguildcommands}
1313

1414
namespace DiscordCoreAPI {
1515

16-
class Test : public DiscordCoreAPI::BaseFunction {
16+
class Test : public BaseFunction {
1717
public:
1818
Test() {
1919
commandName = "test";
2020
helpDescription = "Testing purposes!";
21-
DiscordCoreAPI::EmbedData msgEmbed;
21+
EmbedData msgEmbed;
2222
msgEmbed.setDescription("------\nSimply enter !test or /test!\n------");
2323
msgEmbed.setTitle("__**Test Usage:**__");
2424
msgEmbed.setTimeStamp(getTimeAndDate());
2525
msgEmbed.setColor("FeFeFe");
2626
helpEmbed = msgEmbed;
2727
}
2828

29-
DiscordCoreAPI::UniquePtr<DiscordCoreAPI::BaseFunction> create() {
30-
return DiscordCoreAPI::makeUnique<Test>();
29+
UniquePtr<BaseFunction> create() {
30+
return makeUnique<Test>();
3131
}
3232

33-
virtual void execute(DiscordCoreAPI::BaseFunctionArguments& args) {
34-
vector<DiscordCoreAPI::CreateGuildApplicationCommandData> newVector;
35-
DiscordCoreAPI::CreateGuildApplicationCommandData createSellDrugsCommandData;
33+
virtual void execute(BaseFunctionArguments& args) {
34+
vector<CreateGuildApplicationCommandData> newVector;
35+
CreateGuildApplicationCommandData createSellDrugsCommandData;
3636
createSellDrugsCommandData.description = "Sell drugs in exchange for some currency!";
3737
createSellDrugsCommandData.name = "selldrugs";
38-
createSellDrugsCommandData.type = DiscordCoreAPI::ApplicationCommandType::Chat_Input;
38+
createSellDrugsCommandData.type = ApplicationCommandType::Chat_Input;
3939
newVector.emplace_back(createSellDrugsCommandData);
4040

41-
DiscordCoreAPI::CreateGuildApplicationCommandData registerSlashCommandsCommandData;
41+
CreateGuildApplicationCommandData registerSlashCommandsCommandData;
4242
registerSlashCommandsCommandData.description = "Register the programmatically designated slash commands.";
4343
registerSlashCommandsCommandData.name = "registerslashcommands";
44-
registerSlashCommandsCommandData.type = DiscordCoreAPI::ApplicationCommandType::Chat_Input;
44+
registerSlashCommandsCommandData.type = ApplicationCommandType::Chat_Input;
4545
newVector.emplace_back(registerSlashCommandsCommandData);
4646

47-
DiscordCoreAPI::BulkOverwriteGuildApplicationCommandsData dataPackage;
47+
BulkOverwriteGuildApplicationCommandsData dataPackage;
4848
dataPackage.responseData = newVector;
4949
dataPackage.guildId = args.eventData.getGuildId();
5050

51-
auto returnValue = DiscordCoreAPI::ApplicationCommands::bulkOverwriteGuildApplicationCommandsAsync(dataPackage).get();
51+
auto returnValue = ApplicationCommands::bulkOverwriteGuildApplicationCommandsAsync(dataPackage).get();
5252

5353
for (auto value: returnValue) {
54-
cout << "Command Name: " << value.name << endl;
54+
std::cout << "Command Name: " << value.name << std::endl;
5555
}
5656
}
5757
};

0 commit comments

Comments
 (0)