D++ Extremely Lightweight C++ Discord Library

D++

An incredibly lightweight C++ Discord library

This project is in alpha stages of development.

Completed so far:

  • Websocket connection with heartbeat keepalive and connection resuming
  • Caching system for guilds, channels, guild members, roles, users
  • Event dispatcher - currently only dispatches a subset of messages including e.g. on_message_create and on_guild_create
  • Ability to attach handlers to events
  • REST HTTPS call system using cpp-httplib
  • Message send (dpp::cluster::message_create())
  • Embeds
  • Ratelimit system
  • Windows support

To do:

  • Add the rest of the discord events
  • Add the REST of the HTTP calls (pun intended)
  • Ability to receive raw json strings to event handlers
  • Shard manager
  • Cluster management
  • File uploading

Want to help? Drop me a line or send me a PR. I'll be choosy about what PRs i accept whilst the library is in such a heavy state of development.

It is my intention to get this stable enough to use on my production bot, TriviaBot.

Documentation

Documentation will be here in the project wiki when the project is more complete.

Supported OSes

The library runs best on Linux. Windows is supported via cmake and Visual Studio 2019 but not encouraged for production use. The library may work fine in other operating systems too, but with no access to these we cannot support them.

Dependencies

External Dependencies (You must install these)

  • cmake (version 3.13+)
  • g++ (version 8+)
  • OpenSSL (whichever -dev package comes with your OS)

Included Dependencies (Packaged with the library)

Linux Setup

1. Build Source Code

mkdir build
cd build
cmake ..
make -j8

Replace the number after -j with a number suitable for your setup, usually the same as the number of cores on your machine. cmake will fetch any dependencies that are required for you and ensure they are compiled alongside the library.

2. Run test cases

run ./test for unit test cases.

3. Install to /usr/local/include and /usr/local/lib

make install coming soon!

Owner
brainbox.cc
Creating fun stuff since 1993.
brainbox.cc
Comments
  • Any chance of a pre-compiled 32-bit version for Windows?

    Any chance of a pre-compiled 32-bit version for Windows?

    My intended application to use D++ in, is currently built for 32-bit.

    I followed the build instructions in the Documentation and it defaults to x64 debug. My attempts at switching to 32-bit architecture haven't worked thus far, and using CMake-Gui to generate a solution (which deviates from the recommended build procedure) appears to cause some unresolved external symbol issues. Perhaps because the packaged libraries are all x64?

  • Making `dpp.rc` file

    Making `dpp.rc` file

    • When building, it will show more info for dpp.dll file (on Windows properties selection).
    • Haven't tried to build yet because my pc crashed :( (testing help)
  • Stuff

    Stuff

    Add usefull stuff 😳

    bot.on_message_create([&bot](const dpp::message_create_t& message) {
    //Example:
    if(message.author.bot) return;
    		message.reply("ok");
    		});
    

    message.author should be added with: (send, user object (bot boolean, user id, username, discriminator etc..))

  • Could NOT find sodium (missing: sodium_LIBRARY_RELEASE sodium_LIBRARY_DEBUG)

    Could NOT find sodium (missing: sodium_LIBRARY_RELEASE sodium_LIBRARY_DEBUG)

    Describe the bug Hi, when I tried to build dpp from source, I run cmake -B ./build then it's failed because sodium package is not found, although I downloaded the package (libsodium-dev)

    Screenshots Web capture_4-8-2022_17339_abdfnx-botway-q7qpqjxrg295rr github dev

    System Details:

    • OS: Ubuntu
    • Discord Client used for testing: web
  • Build gets stuck at %5 (cluster.cpp.o)

    Build gets stuck at %5 (cluster.cpp.o)

    Describe the bug Running make -j1 on a RPI Zero gets stuck at 5%

    To Reproduce Steps to reproduce the behavior:

    1. cd build
    2. cmake ..
    3. make -j1

    Expected behavior Building without getting stuck

    System Details: RPI Zero, Raspberry Pi OS g++ 8.3.0

  • missing heartbeat handling?

    missing heartbeat handling?

    Describe the bug Instead of sending a heartbeat to the discord servers every ~40 seconds the connection is shutdown with code 1000 every minute (and immediately reconnected). After the connection is closed unexpectedly (eg. TCP error) the disconnect seems to be unhandled.

    To Reproduce I noticed the disconnect issue after I suspended my computer. After wakeup the bot was naturally disconnected from discord servers but the library never noticed or fixed this. All logs (even trace) stay empty.

    Expected behavior

    • According to Discord documentation: first heartbeat after a random duration <= heartbeat_interval, subsequently one haertbeat every heartbeat_interval milliseconds.
    • Automatic resume, on failure reconnect if the connection is closed without a terminating message by discord servers.

    System Details:

    • used commit 02cd5aa908cf614c9c6fe27aa3bff8ac9092f041 to test
  • dpp::cluster::thread_create_in_forum() crashes the bot without a clear error when the bot has insufficient permissions

    dpp::cluster::thread_create_in_forum() crashes the bot without a clear error when the bot has insufficient permissions

    Git commit reference d4b74dae5a3fd7d2f7e9f458c90c16c4fc4fa588

    Describe the bug When dpp::cluster::thread_create_in_forum() is used in a channel where the bot does not have the correct permissions to create a post, the bot crashes without any clear errors (see screenshot further down).

    Steps to reproduce the behavior: run dpp::cluster::thread_create_in_forum() on a channel the bot does not have the Create Posts permission for

    Expected behavior Something along the lines of what bot.message_create() would do in the case of missing permissions: Outputting an error code along with the API response to the terminal, showing that the bot does not have the correct permissions. And most importantly, not crash the bot in the process.

    Currently however, the bot just terminates with little information about the reason, see screenshot image

    • OS: Ubuntu 20.04.5 LTS x86_64
  • compile error

    compile error

    /usr/bin/ld: warning: libssl.so.3, needed by /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_3.0.0' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to [email protected]_2.34' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/libdpp.so: undefined reference to[email protected]_2.34' collect2: error: ld returned 1 exit status

  • Audio artifacts when streaming uncompressed audio w/ send_audio_raw

    Audio artifacts when streaming uncompressed audio w/ send_audio_raw

    Running tip, 45c509fb763f0b6d34494d546c802986ac15d648.

    I'm trying to stream uncompressed PCM audio into DPP in this manner:

    const int kAudioBufferCount = 4; // length of the audio buffer chain in DPP
    
    bot.on_voice_buffer_send([&](const dpp::voice_buffer_send_t& event) {
    	int buffer_size = event.buffer_size;
    
    	while (buffer_size < kAudioBufferCount) {
    		// Get exactly 11520 bytes of 48khz, stereo, signed 16-bit PCM
    		PCM block = PopAudio();
    
    		event.voice_client->send_audio_raw((uint16_t*)block.data, block.size);
    
    		++buffer_size;
    	}
    });
    

    This nearly works - I hear the streamed sound from Discord Web - but there are frequent glitches.

    I added some code to measure the rate at which I'm passing samples into DPP and measuring ~47364 Hz, not 48k. I'm definitely not underflowing -- event.buffer_size doesn't drop below 3.

    The artifacts sound like skipped chunks waveform to me, not resampling.

    Any idea why DPP would be requesting at less than the full rate? Or is the above call pattern incorrect for a streaming use case?

  • `edit_response` seems like a bug

    `edit_response` seems like a bug

    Version: Dpp 10.0.10

    Command use: edit_response() for edit bot message reply. Problem: it thrown me a webhook error. Error log:

    ] ERROR: Error 10015 [Unknown Webhook] on API request, returned
    			content was: {"message": "Unknown Webhook", "code": 10015}
    

    Steps to do:

    event.edit_response(
    	dpp::message()
    		.set_flags(dpp::m_ephemeral)
    		.set_content(kick_content)
    );
    

    Photos: image image

  • Fix modal placeholder and title, and add set_value function

    Fix modal placeholder and title, and add set_value function

    According to the Discord API, text inputs have 100 characters as the placeholder limit, while select menus have 150 characters as the placeholder limit.

    This PR sets the limit for text inputs to 100 chars instead of 150.

  • Can't install precompiled on RPi4 - Unmet Dependencies

    Can't install precompiled on RPi4 - Unmet Dependencies

    Git commit reference I downloaded precompiled binary

    Describe the bug I have a RPi4 with DietPi(Debian) on it I tried to sudo apt install ./libdpp-10.0.21-linux-rpi-arm64.deb but it ends up throwing error about unmet dependencies.

    I have installed those dependencies, although I have them on arm version, I see DPP it's asking for aarch version

    Expected behavior

    Binary should be installed

    Screenshots

    image

    System Details:

    • OS: DietPi (Debian) image
  • Package manager support

    Package manager support

    Is your feature request related to a problem? Please describe. Vcpkg or conan support help alleviate the setup for multiple libraries in a project. They help to get started quickly with a framework while still allowing other libraries to be added quickly.

    Describe the solution you'd like Rather than premade build setups, I think that having vcpkg or conan support would enable more ambitious discord bots to be created faster.

    Describe alternatives you've considered

    Additional context

    Tasks added by @braindigitalis

    • [x] vcpkg
    • [x] xmake
    • [x] AUR
    • [x] SW Network
    • [x] Libhunt
    • [ ] apt, custom repository
    • [ ] yum
    • [ ] conan
    • [ ] void linux XBPS
    • [ ] gentoo emerge/GURU
Lightweight single-file utilities for C99. Portable & zero dependency

plainlibs Lightweight single-file utilities for C99. Key Features Portable across Unix & Windows (including MSVC) Zero dependencies (besides C stdlib)

Oct 5, 2022
Libft is an individual project at 42 that requires us to re-create some standard C library functions including some additional ones that can be used later to build a library of useful functions for the rest of the program.

?? Index What is Libft? List of Functions Technologies ✨ What is Libft? Libft is an individual project at 42 that requires us to re-create some standa

Jan 17, 2022
Library that simplify to find header for class from STL library.

Library that simplify to find header for class from STL library. Instead of searching header for some class you can just include header with the class name.

Jun 7, 2022
Thrust is a C++ parallel programming library which resembles the C++ Standard Library.

Thrust: Code at the speed of light Thrust is a C++ parallel programming library which resembles the C++ Standard Library. Thrust's high-level interfac

Dec 31, 2022
jkds is a modern header-only C++20 library that complements the standard library.

jkds is a modern header-only C++20 library that complements the standard library. It provides generic atypical data structures, ergonomic functional programming abstractions, and then some.

Nov 16, 2022
Bionic BSD-3-ClauseBionic - Google's standard library, developed for Android. BSD-3-Clause

bionic bionic is Android's C library, math library, and dynamic linker. Using bionic as an app developer See the user documentation. Working on bionic

Dec 31, 2022
CloudABI's standard C library

NOTE: This project is unmaintained CloudABI is no longer being maintained. It was an awesome experiment, but it never got enough traction to be sustai

Dec 15, 2022
libcu++: The C++ Standard Library for Your Entire System

libcu++, the NVIDIA C++ Standard Library, is the C++ Standard Library for your entire system. It provides a heterogeneous implementation of the C++ Standard Library that can be used in and between CPU and GPU code.

Jan 2, 2023
EASTL stands for Electronic Arts Standard C++ Template Library

EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.

Dec 27, 2022
An open source standard C library that includes useful functions && (Reimplementation of libc functions + own functions).
An open source standard C library that includes useful functions && (Reimplementation of libc functions + own functions).

?? LIBFT-42 : Artistic view of LIBC: ?? HOW DOES IT FEEL HAVING YOUR OWN LIB: SUBJECT : ENGLISH PDF ℹ️ What is LIBFT : This project aims to code a C l

Nov 4, 2022
Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags.
Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags.

Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags. Quick start #include <bitflags/bitf

Nov 22, 2022
expected lite - Expected objects in C++11 and later in a single-file header-only library

expected lite: expected objects for C++11 and later expected lite is a single-file header-only library for objects that either represent a valid value

Jan 4, 2023
Guidelines Support Library

GSL: Guidelines Support Library The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guideline

Jan 7, 2023
gsl-lite – A single-file header-only version of ISO C++ Guidelines Support Library (GSL) for C++98, C++11, and later

gsl-lite: Guidelines Support Library for C++98, C++11 up metadata build packages try online gsl-lite is an implementation of the C++ Core Guidelines S

Jan 7, 2023
Your standard library for metaprogramming

Boost.Hana Your standard library for metaprogramming Overview #include <boost/hana.hpp> #include <cassert> #include <string> namespace hana = boost::h

Jan 8, 2023
C++11 metaprogramming library

Mp11, a C++11 metaprogramming library Mp11 is a C++11 metaprogramming library based on template aliases and variadic templates. It implements the appr

Jan 9, 2023
optional lite - A C++17-like optional, a nullable object for C++98, C++11 and later in a single-file header-only library

optional lite: A single-file header-only version of a C++17-like optional, a nullable object for C++98, C++11 and later Contents Example usage In a nu

Dec 28, 2022
Range library for C++14/17/20, basis for C++20's std::ranges

range-v3 Range library for C++14/17/20. This code was the basis of a formal proposal to add range support to the C++ standard library. That proposal e

Dec 29, 2022
span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library

span lite: A single-file header-only version of a C++20-like span for C++98, C++11 and later Contents Example usage In a nutshell License Dependencies

Dec 31, 2022