Skip to content
Closed
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
12 changes: 11 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" OFF)

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

if (DPP_MODULES)
add_subdirectory(src/modules)
target_compile_definitions(dpp PUBLIC DPP_MODULES)
message("-- C++20 Modules support: ${Green}ENABLED${ColourReset}")
else()
message("-- C++20 Modules support: ${Red}DISABLED${ColourReset} (enable with -DDPP_MODULES=ON)")
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

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

Expand Down
1 change: 1 addition & 0 deletions docpages/example_programs/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ This section lists examples that do not fit neatly into any of the categories ab
* \subpage setting_status
* \subpage using-emojis
* \subpage using_timers
* \subpage using_modules
33 changes: 33 additions & 0 deletions docpages/example_programs/misc/using_modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
\page making_a_http_request Making Arbitrary HTTP Requests Using D++

If you wish to make arbitrary HTTP(S) requests to websites and APIs, e.g. to update statistics on bot lists, you can use code similar to the code below. You may pass any arbitrary POST data:

```cpp
import std;
import dpp;

using dpp::cluster;
using dpp::slashcommand;
using dpp::start_type;

int main() {
cluster bot(std::getenv("BOT_TOKEN"));

bot.on_slashcommand([](auto event) {
if (event.command.get_command_name() == "ping") {
event.reply("Pong!");
}
});

bot.on_ready([&bot](auto event) {
if (dpp::run_once<struct RegisterBotCommands>()) {
bot.global_command_create(
slashcommand("ping", "Ping pong!", bot.me.id)
);
}
});

bot.start(start_type::st_wait);
return 0;
}
```
2 changes: 1 addition & 1 deletion include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace dpp {
* requests to Discord. This is useful for bots that do not need to receive websocket events as it will save a lot of
* resources.
*/
constexpr uint32_t NO_SHARDS = ~0U;
inline constexpr uint32_t NO_SHARDS = ~0U;

/**
* @brief Types of startup for cluster::start()
Expand Down
2 changes: 1 addition & 1 deletion include/dpp/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace dpp {
* @brief predefined color constants.
*/
namespace colors {
static constexpr uint32_t
inline constexpr uint32_t
white = 0xFFFFFF,
discord_white = 0xFFFFFE,
light_gray = 0xC0C0C0,
Expand Down
2 changes: 1 addition & 1 deletion include/dpp/discordclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class cluster;
* @brief How many seconds to wait between (re)connections. DO NOT change this.
* It is mandated by the Discord API spec!
*/
constexpr time_t RECONNECT_INTERVAL = 5;
inline constexpr time_t RECONNECT_INTERVAL = 5;

/**
* @brief Represents different event opcodes sent and received on a shard websocket
Expand Down
2 changes: 1 addition & 1 deletion include/dpp/etf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace dpp {
/**
* @brief Current ETF format version in use
*/
const uint8_t FORMAT_VERSION = 131;
inline const uint8_t FORMAT_VERSION = 131;

/**
* @brief Represents a token which identifies the type of value which follows it
Expand Down
4 changes: 2 additions & 2 deletions include/dpp/httpsclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

namespace dpp {

static inline const std::string http_version = "DiscordBot (https://github.com/brainboxdotcc/DPP, "
inline const std::string http_version = "DiscordBot (https://github.com/brainboxdotcc/DPP, "
+ to_hex(DPP_VERSION_MAJOR, false) + "." + to_hex(DPP_VERSION_MINOR, false) + "." + to_hex(DPP_VERSION_PATCH, false) + ")";

static inline constexpr const char* DISCORD_HOST = "https://discord.com";
inline constexpr const char* DISCORD_HOST = "https://discord.com";

/**
* @brief HTTP connection status
Expand Down
14 changes: 7 additions & 7 deletions include/dpp/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -2010,37 +2010,37 @@ namespace embed_type {
/**
* @brief Rich text
*/
const std::string emt_rich = "rich";
inline const std::string emt_rich = "rich";

/**
* @brief Image
*/
const std::string emt_image = "image";
inline const std::string emt_image = "image";

/**
* @brief Video link
*/
const std::string emt_video = "video";
inline const std::string emt_video = "video";

/**
* @brief Animated gif
*/
const std::string emt_gifv = "gifv";
inline const std::string emt_gifv = "gifv";

/**
* @brief Article
*/
const std::string emt_article = "article";
inline const std::string emt_article = "article";

/**
* @brief Link URL
*/
const std::string emt_link = "link";
inline const std::string emt_link = "link";

/**
* @brief Auto moderation filter
*/
const std::string emt_automod = "auto_moderation_message";
inline const std::string emt_automod = "auto_moderation_message";
} // namespace embed_type

/**
Expand Down
Loading