Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/test-docs-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:
jobs:
test_docs_examples:
name: Test build examples
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -35,17 +35,19 @@ jobs:
submodules: recursive

- name: Install apt packages
run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt-get update && sudo apt-get install -y g++-12 libopus-dev zlib1g-dev libmpg123-dev liboggz-dev cmake libfmt-dev libopusfile-dev
run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt-get update && sudo apt-get install -y clang-20 libopus-dev ninja-build zlib1g-dev libmpg123-dev liboggz-dev cmake libfmt-dev libopusfile-dev

- name: Generate CMake
run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DAVX_TYPE=T_fallback -DDPP_CORO=ON -DCMAKE_BUILD_TYPE=Debug ..
run: mkdir build && cd build && cmake -G Ninja -DDPP_NO_VCPKG=ON -DDPP_MODULES=ON -DAVX_TYPE=T_fallback -DDPP_CORO=ON -DCMAKE_BUILD_TYPE=Debug ..
env:
CXX: g++-12
CXX: clang++-20

- name: Build Project
run: cd build && make -j2 && sudo make install
run: cd build && cmake --build . -j2 && sudo ninja install
env:
CXX: clang++-20

- name: Test compile examples
run: cd docpages/example_code && mkdir build && cd build && cmake .. && make -j2
run: cd docpages/example_code && mkdir build && cd build && cmake -G Ninja -DDPP_MODULES=ON .. && cmake --build . -j2
env:
CXX: g++-12
CXX: clang++-20
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

cmake_minimum_required (VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_VOICE_SUPPORT "Build voice support" ON)
option(RUN_LDCONFIG "Run ldconfig after installation" ON)
Expand All @@ -33,6 +33,7 @@ option(DPP_USE_EXTERNAL_JSON "Use an external installation of nlohmann::json" OF
option(DPP_USE_PCH "Use precompiled headers to speed up compilation" OFF)
option(AVX_TYPE "Force AVX type for speeding up audio mixing" OFF)
option(DPP_TEST_VCPKG "Force VCPKG build without VCPKG installed (for development use only!)" OFF)
option(DPP_MODULES "Support for C++20 modules (experimental)" OFF)

include(CheckCXXSymbolExists)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down Expand Up @@ -159,3 +160,4 @@ endif()
if (NOT WIN32)
target_link_libraries(dpp PRIVATE std::filesystem)
endif()

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ D++ is a lightweight and efficient library for **Discord** written in **modern C
* Stable [Windows support](https://dpp.dev/buildwindows.html)
* Ready-made compiled packages for Windows, Raspberry Pi (ARM64/ARM7/ARMv6), Debian x86/x64, and RPM based distributions
* Highly scalable for large amounts of guilds and users
* Support for [C++ modules](https://dpp.dev/using_modules.html)

Want to help? Drop me a line or send a PR.

Expand Down
44 changes: 32 additions & 12 deletions cmake/CPackSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,40 @@ set(DPP_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}/${DPP_VERSIONED})

## Pack the binary output
if (WIN32)
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${DPP_INSTALL_INCLUDE_DIR})
if (DPP_MODULES)
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${DPP_INSTALL_INCLUDE_DIR}
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dpp/include)
else()
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${DPP_INSTALL_INCLUDE_DIR})
endif()
install(DIRECTORY "${DPP_ROOT_PATH}/include/" DESTINATION "${DPP_INSTALL_INCLUDE_DIR}")
else()
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR})
if (DPP_MODULES)
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR}
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dpp/include)
else()
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR})
endif()
endif()

## Allow for a specific version to be chosen in the `find_package` command
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ project(documentation_tests)

string(ASCII 27 Esc)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDPP_CORO -std=c++20 -pthread -O0 -fPIC -rdynamic -DFMT_HEADER_ONLY -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter -Wno-deprecated-declarations")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDPP_CORO -DDPP_MODULES -std=c++20 -pthread -O0 -fPIC -DFMT_HEADER_ONLY -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter -Wno-deprecated-declarations")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")

file(GLOB example_list ./*.cpp)
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/attachments1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "file") {
dpp::message msg(event.command.channel_id, "Hey there, I've got a new file!");
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/attachments3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "file") {
/* Create a message. */
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/autocomplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main()
});

/* The interaction create event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
bot.on_slashcommand([](const dpp::slashcommand_t & event) {

/* Check which command they ran */
if (event.command.get_command_name() == "blep") {
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/cache_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main() {
});

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot, &message_cache](const dpp::slashcommand_t& event) {
bot.on_slashcommand([&message_cache](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "get") {

Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "button") {
/* Create a message */
Expand All @@ -33,7 +33,7 @@ int main() {
/* When a user clicks your button, the on_button_click event will fire,
* containing the custom_id you defined in your button.
*/
bot.on_button_click([&bot](const dpp::button_click_t& event) {
bot.on_button_click([](const dpp::button_click_t& event) {
/* Button clicks are still interactions, and must be replied to in some form to
* prevent the "this interaction has failed" message from Discord to the user.
*/
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/components2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "math") {

Expand Down Expand Up @@ -40,7 +40,7 @@ int main() {
}
});

bot.on_button_click([&bot](const dpp::button_click_t & event) {
bot.on_button_click([](const dpp::button_click_t & event) {
if (event.custom_id == "10") {
event.reply(dpp::message("You got it right!").set_flags(dpp::m_ephemeral));
} else {
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/components3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "select") {
/* Create a message */
Expand All @@ -33,7 +33,7 @@ int main() {
/* When a user clicks your select menu , the on_select_click event will fire,
* containing the custom_id you defined in your select menu.
*/
bot.on_select_click([&bot](const dpp::select_click_t & event) {
bot.on_select_click([](const dpp::select_click_t & event) {
/* Select clicks are still interactions, and must be replied to in some form to
* prevent the "this interaction has failed" message from Discord to the user.
*/
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/components3_rolemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "select") {
/* Create a message */
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/default_select_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "select") {
/* Create a message */
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/detecting_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when the bot detects a message in any server and any channel it has access to. */
bot.on_message_create([&bot](const dpp::message_create_t& event) {
bot.on_message_create([](const dpp::message_create_t& event) {
/* See if the message contains the phrase we want to check for.
* If there's at least a single match, we reply and say it's not allowed.
*/
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/editing_message_after_click.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "button") {
/* Create a message */
Expand All @@ -33,7 +33,7 @@ int main() {
/* When a user clicks your button, the on_button_click event will fire,
* containing the custom_id you defined in your button.
*/
bot.on_button_click([&bot](const dpp::button_click_t& event) {
bot.on_button_click([](const dpp::button_click_t& event) {
/* Instead of replying to the button click itself,
* we want to update the message that had the buttons on it.
*/
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/editing_message_after_click2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "button") {
/* Create a message */
Expand All @@ -33,7 +33,7 @@ int main() {
/* When a user clicks your button, the on_button_click event will fire,
* containing the custom_id you defined in your button.
*/
bot.on_button_click([&bot](const dpp::button_click_t& event) {
bot.on_button_click([](const dpp::button_click_t& event) {
/* Instead of replying to the button click itself,
* we want to update the message that had the buttons on it.
*/
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/embeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "embed") {
/* Create an embed */
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/ephemeral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
bot.on_slashcommand([](const dpp::slashcommand_t & event) {
/* Check which command they ran */
if (event.command.get_command_name() == "hello") {
/* Reply to the user, but only let them see the response. */
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main() {
* This code assumes the current directory is writeable. The file will have a
* unique name made from the user's id and the message id.
*/
std::string source_filename = std::to_string(event.msg.author.id) + "_" + std::to_string(event.msg.id) + ".cpp";
std::string source_filename = std::to_string(event.msg.author.id) + "_" + std::to_string(event.msg.id) + ".cpp";
std::fstream code_file(source_filename, std::fstream::binary | std::fstream::out);
if (!code_file.is_open()) {
bot.message_create(dpp::message(event.msg.channel_id, "Unable to create source file for `eval`"));
Expand All @@ -96,7 +96,7 @@ int main() {
std::to_string(event.msg.author.id) + "_" + std::to_string(event.msg.id) + ".cpp",
"-ldpp",
"-ldl"
}, [event, &bot, source_filename, compile_start](const std::string &output) {
}, [event, &bot, compile_start](const std::string &output) {

/* After g++ is ran we end up inside this lambda with the output as a string */
double compile_time = dpp::utility::time_f() - compile_start;
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/join_voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {

/* Check which command they ran */
if (event.command.get_command_name() == "join") {
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/modal_dialog_interactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main() {

bot.on_log(dpp::utility::cout_logger());

bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
/* Check for our /dialog command */
if (event.command.get_command_name() == "dialog") {
/* Instantiate an interaction_modal_response object */
Expand Down
6 changes: 3 additions & 3 deletions docpages/example_code/mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ int main() {
mpg123_open(mh, MUSIC_FILE);
mpg123_getformat(mh, &rate, &channels, &encoding);

unsigned int counter = 0;
for (int totalBytes = 0; mpg123_read(mh, buffer, buffer_size, &done) == MPG123_OK; ) {
[[maybe_unused]] unsigned int counter = 0;
for ([[maybe_unused]] int totalBytes = 0; mpg123_read(mh, buffer, buffer_size, &done) == MPG123_OK; ) {
for (size_t i = 0; i < buffer_size; i++) {
pcmdata.push_back(buffer[i]);
}
Expand All @@ -59,7 +59,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot, &pcmdata](const dpp::slashcommand_t& event) {
bot.on_slashcommand([&pcmdata](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "join") {
/* Get the guild */
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/oggopus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main(int argc, char const *argv[]) {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {

/* Check which command they ran */
if (event.command.get_command_name() == "join") {
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/oggopus2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
bot.on_slashcommand([](const dpp::slashcommand_t& event) {

/* Check which command they ran */
if (event.command.get_command_name() == "join") {
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/record_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot, &fd](const dpp::slashcommand_t& event) {
bot.on_slashcommand([&fd](const dpp::slashcommand_t& event) {
/* Check which command they ran */
if (event.command.get_command_name() == "record") {
/* Get the guild */
Expand All @@ -43,7 +43,7 @@ int main() {
}
});

bot.on_voice_receive([&bot, &fd, &user_id](const dpp::voice_receive_t &event) {
bot.on_voice_receive([&fd, &user_id](const dpp::voice_receive_t &event) {
if (event.user_id == user_id) {
fwrite((char *)event.audio, 1, event.audio_size, fd);
}
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/slashcommands1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main() {
bot.on_log(dpp::utility::cout_logger());

/* The event is fired when someone issues your commands */
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
bot.on_slashcommand([](const dpp::slashcommand_t & event) {
/* Check which command they ran */
if (event.command.get_command_name() == "blep") {
/* Fetch a parameter value from the command parameters */
Expand Down
Loading
Loading