Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #103

Merged
merged 24 commits into from
Aug 23, 2023
Merged

Dev #103

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fd6caca
docs: Fixed some doc pages with errors. (#784)
Jaskowicz1 Aug 20, 2023
c415bf5
docs: added docs page about checking permissions (#777)
Commandserver Aug 20, 2023
7b42b15
Updating to the correct AVX2 instruction.
RealTimeChris Aug 21, 2023
541bd9a
Merge branch 'dev' into master
RealTimeChris Aug 21, 2023
83c824d
fix: make cmakelists use the correct AVX2 instruction (#786)
RealTimeChris Aug 21, 2023
570378a
ci: create .clabot for CLA agreements for new contribs (#787)
braindigitalis Aug 21, 2023
ed0e3e2
ci: create .onefuzz to make scorecard happy (#790)
braindigitalis Aug 21, 2023
7e4000f
ci: delete .clabot, not required for new cla/dco bot (#789)
braindigitalis Aug 21, 2023
729fced
refactor(coro): renamed dpp::awaitable to dpp::async
Mishura4 Aug 8, 2023
29cd0f0
feat(coro): dpp::job, a lightweight async coroutine
Mishura4 Aug 10, 2023
f8dbd58
build(coro): add "resumer" to spelling checks
Mishura4 Aug 10, 2023
d662ee3
style(coro): split coro.h into its own folder
Mishura4 Aug 10, 2023
cb6a103
feat(coro): coroutine<R>, a lightweight synchronized coroutine object
Mishura4 Aug 10, 2023
1b33499
perf(coro): lock free dpp::async
Mishura4 Aug 18, 2023
d18fb48
feat(coro): dpp::task::cancel(), lock-free dpp::task
Mishura4 Aug 12, 2023
54eaffa
test: add enum for test status and type, make each test a variable, a…
Mishura4 Aug 15, 2023
2cbc430
docs(coro): update docs for PR #763
Mishura4 Aug 21, 2023
6c344a1
feat: coroutines "beta test" (#763)
braindigitalis Aug 21, 2023
8985170
ci: force reupload with clobber, and sign a copy of the source archiv…
braindigitalis Aug 22, 2023
f92adb4
feat(build): add off-by-default DPP_USE_PCH option in CMake (#793)
Mishura4 Aug 22, 2023
af3247a
ci: we have to silence error reporting here or we get stderr intermix…
braindigitalis Aug 22, 2023
e1e3ea3
docs: fixed several small things in docs (#797)
wizard7377 Aug 23, 2023
7faa78a
docs: improved Jenkins page. (#798)
Jaskowicz1 Aug 23, 2023
2e6f6b8
docs: Added a new page for on_message_create and changed warnings abo…
Jaskowicz1 Aug 23, 2023
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
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"stringified",
"disdppgloss",
"awaiter",
"resumer",
"checkered",
"ramen",
"dango",
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- [ ] I have ensured that I did not break any existing API calls.
- [ ] My code follows the [coding style guide](https://dpp.dev/coding-standards.html) (if you are not sure, match the code style of existing files including indent style etc).
- [ ] I have not built my pull request using AI, a static analysis tool or similar without any human oversight. Where I have generated this pull request using a tool, I have justified why this is needed.
- [ ] I agree to the terms of the [DCO (Developer Certificate of Origin)]((https://dpp.dev/coding-standards.html))

1 change: 1 addition & 0 deletions .onefuzz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ option(DPP_BUILD_TEST "Build the test program" ON)
option(DPP_NO_VCPKG "No VCPKG" OFF)
option(DPP_CORO "Experimental support for C++20 coroutines" OFF)
option(DPP_USE_EXTERNAL_JSON "Use an external installation of nlohmann::json" OFF)
option(DPP_USE_PCH "Use precompiled headers to speed up compilation" OFF)

include(CheckCXXSymbolExists)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
10 changes: 6 additions & 4 deletions buildtools/classes/Generator/CoroGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ public function checkForChanges(): bool
*/
public function generateHeaderDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterTypes, string $parameterNames): string
{
return "awaitable<confirmation_callback_t> co_{$currentFunction}($parameters);\n\n";
return "[[nodiscard]] async<confirmation_callback_t> co_{$currentFunction}($parameters);\n\n";
}

/**
* @inheritDoc
*/
public function generateCppDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterTypes, string $parameterNames): string
{
return "awaitable<confirmation_callback_t> cluster::co_${currentFunction}($noDefaults) {\n\treturn {this, static_cast<void (cluster::*)($parameterTypes". (!empty($parameterTypes) ? ", " : "") . "command_completion_event_t)>(&cluster::$currentFunction)$parameterNames};\n}\n\n";
/* if (substr($parameterNames, 0, 2) === ", ")
$parameterNames = substr($parameterNames, 2); */
return "async<confirmation_callback_t> cluster::co_${currentFunction}($noDefaults) {\n\treturn async{ this, static_cast<void (cluster::*)($parameterTypes". (!empty($parameterTypes) ? ", " : "") . "command_completion_event_t)>(&cluster::$currentFunction)$parameterNames };\n}\n\n";
}

/**
Expand All @@ -114,7 +116,7 @@ public function getCommentArray(): array
*/
public function saveHeader(string $content): void
{
$content .= "awaitable<http_request_completion_t> co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap<std::string, std::string> &headers = {});\n\n";
$content .= "[[nodiscard]] async<http_request_completion_t> co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap<std::string, std::string> &headers = {});\n\n";
file_put_contents('include/dpp/cluster_coro_calls.h', $content);
}

Expand All @@ -123,7 +125,7 @@ public function saveHeader(string $content): void
*/
public function saveCpp(string $cppcontent): void
{
$cppcontent .= "dpp::awaitable<dpp::http_request_completion_t> dpp::cluster::co_request(const std::string &url, http_method method, const std::string &postdata, const std::string &mimetype, const std::multimap<std::string, std::string> &headers) {\n\treturn awaitable<http_request_completion_t>{[&](auto &&cc) { this->request(url, method, cc, postdata, mimetype, headers); }};\n}
$cppcontent .= "dpp::async<dpp::http_request_completion_t> dpp::cluster::co_request(const std::string &url, http_method method, const std::string &postdata, const std::string &mimetype, const std::multimap<std::string, std::string> &headers) {\n\treturn async<http_request_completion_t>{ [&, this] <typename C> (C &&cc) { return this->request(url, method, std::forward<C>(cc), postdata, mimetype, headers); }};\n}

#endif
";
Expand Down
4 changes: 2 additions & 2 deletions cmake/DetectArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ endfunction()
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(INSTRUCTION_SETS
"T_AVX?/arch:AVX?auto result = _mm_testz_ps(__m128{}, __m128{})"
"T_AVX2?/arch:AVX2?auto result = _mm256_extract_epi64(__m256i{}, 0)"
"T_AVX2?/arch:AVX2?auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
"T_AVX512?/arch:AVX512?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})"
)
else()
set(INSTRUCTION_SETS
"T_AVX?-mavx.-mpclmul.-mbmi?auto result = _mm_testz_ps(__m128{}, __m128{})"
"T_AVX2?-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm256_extract_epi64(__m256i{}, 0)"
"T_AVX2?-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
"T_AVX512?-mavx512bw.-mavx512f.-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})"
)
endif()
Expand Down
6 changes: 3 additions & 3 deletions docpages/01_frequently_asked_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ In production on TriviaBot, the bot takes approximately 2gb of ram to run 18 sep
For a very small bot, you can get the memory usage as low as **6 megabytes** on a Raspberry Pi.

## How do I use this library in Windows?
The easiest way is to use our [template project](https://github.com/brainboxdotcc/windows-bot-template). If you are unable to do this, download the precompiled latest release from our GitHub releases, and take the dlls, .lib file, and header files (`bin`, `lib` and `include` directories), placing them in a easily accessible place on your computer. Go into Visual Studio project settings in a new project, and point the project directories (notably the library directories and and include directories) at the correct locations. Add the `include` folder you extracted to your include directories, and add `dpp.lib` to your library directories. Ensure the project is set to C++17 standard in the settings. You should then be able to compile example programs within that project. When you run the program you have compiled you must ensure that all the dll files from the `bin` directory exist in the same directory as your executable.
The easiest way is to use our [template project](https://github.com/brainboxdotcc/windows-bot-template). If you are unable to do this, download the precompiled latest release from our GitHub releases, and take the dlls, `.lib` file, and header files (`bin`, `lib` and `include` directories), placing them in a easily accessible place on your computer. Go into Visual Studio project settings in a new project, and point the project directories (notably the library directories and and include directories) at the correct locations. Add the `include` folder you extracted to your include directories, and add `dpp.lib` to your library directories. Ensure the project is set to C++17 standard in the settings. You should then be able to compile example programs within that project. When you run the program you have compiled you must ensure that all the dll files from the `bin` directory exist in the same directory as your executable.

## Does this library support Visual Studio 2022?
Yes! The master branch comes with pre-built binaries for Visual Studio 2022 and our windows bot template has a [vs2022 branch](https://github.com/brainboxdotcc/windows-bot-template/tree/vs2022) which you can clone to get Visual Studio 2022 specific code. For the time being we support both Visual Studio 2019 and 2022. At some point in the future only 2022 may be supported as 2019 becomes outdated.
Yes! The master branch comes with pre-built binaries for Visual Studio 2022 and our Windows bot template has a [vs2022 branch](https://github.com/brainboxdotcc/windows-bot-template/tree/vs2022) which you can clone to get Visual Studio 2022 specific code. For the time being we support both Visual Studio 2019 and 2022. At some point in the future only 2022 may be supported as 2019 becomes outdated.

## How much of the library is completed?
All REST calls (outbound commands) are completed including all currently available interactions, and all Discord events are available. The library also has voice support.
Expand All @@ -41,7 +41,7 @@ NO! Definitely not! We have tried to keep things as simple as possible. We only
DPP is short for *D Plus Plus* (D++), a play on the Discord and C++ names. You'll see the library referred to as `dpp` within source code as `d++` is not a valid symbol so we couldn't exactly use that as our namespace name.

## Is D++ a single header library?
No, D++ is a classically designed library which installs itself to your library directory/system directory as a shared object or dll. You must link to its .lib file and include its header files to make use of it. We have no plans for a single-header build.
No, D++ is a classically designed library which installs itself to your library directory/system directory as a shared object or dll. You must link to its `.lib` file and include its header files to make use of it. We have no plans for a single-header build.

## Does this library support slash commands/interactions?
Yes! This library supports slash commands and interactions. For more information please see \ref slashcommands "Using Slash Commands and Interactions".
Expand Down
102 changes: 51 additions & 51 deletions docpages/disdppgloss.md → docpages/02_disdppgloss.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
## A Glossary of Common Discord Terms
This is a list of terms that one should know if you want use D++ (or any other discord library). These terms are not D++ specific, and are commonly used throughout most of the Discord developer community. This list, with a few exceptions, ***is discord specific***, that is to say that this is not a explanation of commonly used C++ terms, it is for people who are not familiar with the terminology of the discord API and libraries themselves.
#### Glossary
Listed in alphabetical order, with terms in bold, here are the basics on...
1. **Action row**: A collection of up to five **components** which is attached to a message.
2. **Audit log**: A log of **events** that have happened in a **guild**.
3. **Auto mod**: Discord's low-code solution to moderation. However, it is very limited in scope.
4. **Badge**: A decoration on someone's profile showing certain things about them, such as if they have nitro, if they are a discord developer, etc.
5. **Bot token**: A secret string of characters that is used as a "login" to your bot. If you lose it or it gets leaked you will have to get a new one from the discord developer portal, so be sure to keep it in a place that is both secure and where you won't forget it.
6. **Button**: A **component** on a message that can be styled that sends an **event** when clicked on by a user.
7. **Cache**: A type of storage efficient for things like messages.
8. **Callback**: While not strictly related to discord, it is used a LOT in D++. A callback is when a function is passed to another function, sort of like how you might give someone a telephone number (you give them the means to do some sort of interaction rather than asking them how to interact), which is used to handle responses to **events**.
9. **Cluster**: A singular bot application, which is composed of one or more **shards**, a **cluster** is the center of bot development.
10. **\(Slash\) command**: The primary way a user interacts with a bot. It is a command sent to the bot with **parameters** (which may be optional) and is initiated by staring a message with `/`.
11. **Component**: A component is anything that can appear in a bot's message besides text, such as **buttons** and **select menus**.
12. **Drop down/Select menu**: A **component** of a message that upon being clicked drops down and allows the user to select an option.
13. **Embeds**: A widget attached to a message which can contain multiple fields of texts, an image, and much more information.
14. **Ephemeral**: A message only visible to the user being replied to.
15. **Event**: Something that a Discord bot can respond to, such as a message being sent, a **button** being clicked, or an option being selected, among others.
16. **Guild**: What the Discord API (and most libraries for it) call a server.
17. **Intents**: The right for a bot to receive certain data from the Discord API.
18. **Interaction**: A object that contains information about whenever a user interacts with a application, such as sending a message or clicking a button. It is the main part of an **event** that will be accessed in an application.
19. **Modal**: A pop up form that contains text that can be sent by a bot.
20. **[Shards](\ref clusters-shards-guilds)**: A shard manages part of the workload of your Discord application
21. **Snowflake**: An unsigned 64 bit integer (it can represent anything from 0 to 2^64-1) that is used by discord to identify basically everything, including but not limited to, **guilds**, users, messages, and much more.
22. **Subcommands**: A command which is derived from a different command, such as a bot that allows a person to get statistics for discord might have a `stats guild` command and a `stats global` command, both of which are **subcommands** of `stats`.
## A Glossary of Common Discord Terms

This is a list of terms that you should know if you want to use D++ (or any other discord library). These terms are not D++ specific, and are commonly used throughout most of the Discord developer community. This list, with a few exceptions, ***is discord specific***, that is to say that this is not a explanation of commonly used C++ terms, it is for people who are not familiar with the terminology of the discord API and libraries themselves.

#### Glossary

Listed in alphabetical order, with terms in bold, here are the basics on...

1. **Action row**: A collection of up to five **components** which is attached to a message.

2. **Audit log**: A log of **events** that have happened in a **guild**.

3. **Auto mod**: Discord's low-code solution to moderation. However, it is very limited in scope.

4. **Badge**: A decoration on someone's profile showing certain things about them, such as if they have nitro, if they are a discord developer, etc.

5. **Bot token**: A secret string of characters that is used as a "login" to your bot. If you lose it or it gets leaked you will have to get a new one from the discord developer portal, so be sure to keep it in a place that is both secure and where you won't forget it.

6. **Button**: A **component** on a message that can be styled that sends an **event** when clicked on by a user.

7. **Cache**: A type of storage efficient for things like messages.

8. **Callback**: While not strictly related to discord, it is used a LOT in D++. A callback is when a function is passed to another function, sort of like how you might give someone a telephone number (you give them the means to do some sort of interaction rather than asking them how to interact), which is used to handle responses to **events**.

9. **Cluster**: A singular bot application, which is composed of one or more **shards**, a **cluster** is the center of bot development.

10. **\(Slash\) command**: The primary way a user interacts with a bot. It is a command sent to the bot with **parameters** (which may be optional) and is initiated by staring a message with `/`.

11. **Component**: A component is anything that can appear in a bot's message besides text, such as **buttons** and **select menus**.

12. **Drop down/Select menu**: A **component** of a message that upon being clicked drops down and allows the user to select an option.

13. **Embeds**: A widget attached to a message which can contain multiple fields of texts, an image, and much more information.

14. **Ephemeral**: A message only visible to the user being replied to.

15. **Event**: Something that a Discord bot can respond to, such as a message being sent, a **button** being clicked, or an option being selected, among others.

16. **Guild**: What the Discord API (and most libraries for it) call a server.

17. **Intents**: The right for a bot to receive certain data from the Discord API.

18. **Interaction**: A object that contains information about whenever a user interacts with a application, such as sending a message or clicking a button. It is the main part of an **event** that will be accessed in an application.

19. **Modal**: A pop up form that contains text that can be sent by a bot.

20. **[Shards](\ref clusters-shards-guilds)**: A shard manages part of the workload of your Discord application

21. **Snowflake**: An unsigned 64 bit integer (it can represent anything from 0 to 2^64-1) that is used by discord to identify basically everything, including but not limited to, **guilds**, users, messages, and much more.

22. **Subcommands**: A command which is derived from a different command, such as a bot that allows a person to get statistics for discord might have a `stats guild` command and a `stats global` command, both of which are **subcommands** of `stats`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

We keep things marked as depreciated until next major API version.
If discord removes the function, we may remove the method from the library or replace it with a thrown exception depending on the type of function and at our discretion.
Such functions which are made to throw will then be removed at the next major API version.
Such functions which are made to throw will then be removed at the next major API version.

<hr>
Loading