Skip to content

Commit cf5e227

Browse files
Merge pull request #97 from brainboxdotcc/dev
Dev
2 parents b2efb42 + 9b2e5cd commit cf5e227

File tree

13 files changed

+731
-58
lines changed

13 files changed

+731
-58
lines changed

CMakeSettings.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,46 @@
33
{
44
"name": "x64-Debug",
55
"generator": "Ninja",
6+
"configurationType": "Debug",
7+
"inheritEnvironments": [ "msvc_x64_x64" ],
8+
"buildRoot": "${projectDir}\\out\\build\\${name}",
9+
"installRoot": "${projectDir}\\out\\install\\${name}",
10+
"cmakeCommandArgs": "",
11+
"buildCommandArgs": "",
12+
"ctestCommandArgs": ""
13+
},
14+
{
15+
"name": "x64-Release",
16+
"generator": "Ninja",
617
"configurationType": "Release",
718
"inheritEnvironments": [ "msvc_x64_x64" ],
819
"buildRoot": "${projectDir}\\out\\build\\${name}",
920
"installRoot": "${projectDir}\\out\\install\\${name}",
1021
"cmakeCommandArgs": "",
1122
"buildCommandArgs": "",
1223
"ctestCommandArgs": ""
24+
},
25+
{
26+
"name": "x64-Debug-Coro",
27+
"generator": "Ninja",
28+
"configurationType": "Debug",
29+
"inheritEnvironments": [ "msvc_x64_x64" ],
30+
"buildRoot": "${projectDir}\\out\\build\\${name}",
31+
"installRoot": "${projectDir}\\out\\install\\${name}",
32+
"cmakeCommandArgs": "-DDPP_CORO=on",
33+
"buildCommandArgs": "",
34+
"ctestCommandArgs": ""
35+
},
36+
{
37+
"name": "x64-Release-Coro",
38+
"generator": "Ninja",
39+
"configurationType": "Release",
40+
"inheritEnvironments": [ "msvc_x64_x64" ],
41+
"buildRoot": "${projectDir}\\out\\build\\${name}",
42+
"installRoot": "${projectDir}\\out\\install\\${name}",
43+
"cmakeCommandArgs": "-DDPP_CORO=on",
44+
"buildCommandArgs": "",
45+
"ctestCommandArgs": ""
1346
}
1447
]
1548
}

CONTRIBUTING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ When contributing to this repository, please do not feel intimidated! We welcome
1515
including indent style etc).
1616
7. Your PR must pass the CI actions before being allowed to be merged. Our PR actions check that the
1717
build will compile on various platforms before release and makes precompiled versions of the library.
18-
8. If you are on the discord server for the project and your PR is accepted, let a moderator know and we
19-
will grant you the 'Contributors' role.
20-
18+
8. Automated changes e.g. via grammarly or a static analysis tool will not usually be accepted into the code without proper thought out justification (by a human being, not an AI or an App) as to why the changes are required. Generally a PR should do more than fix a single spelling error for example as this just takes precious time for something which could be resolved a direct commit to the dev branch.

buildtools/emojis.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22

33
echo "-- Autogenrating include/dpp/unicode_emoji.h\n";
44

5-
$header = "#pragma once\n\nnamespace dpp { namespace unicode_emoji {\n";
5+
$url = "https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json";
6+
7+
$header = <<<END
8+
#pragma once
9+
10+
namespace dpp {
11+
12+
/**
13+
* The unicode emojis in this namespace are auto-generated from {$url}
14+
*
15+
* If you want to use this, you have to pull the header in separately. e.g.
16+
* ```cpp
17+
* #include <dpp/dpp.h>
18+
* #include <dpp/unicode_emoji.h>
19+
* ```
20+
*/
21+
namespace unicode_emoji {
22+
23+
END;
624

725
/* This JSON is generated originally via the NPM package maintained by Discord themselves at https://www.npmjs.com/package/discord-emoji */
8-
$emojis = json_decode(file_get_contents("https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json"));
26+
$emojis = json_decode(file_get_contents($url));
927
if ($emojis) {
1028
foreach ($emojis as $name=>$code) {
1129
if (preg_match("/^\d+/", $name)) {

docpages/05_deprecated_list.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
\page deprecated Deprecated List
2+
3+
### Deprecation policy
4+
5+
We keep things marked as depreciated until next major API version.
6+
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.
7+
Such functions which are made to throw will then be removed at the next major API version.

docpages/example_programs/interactions_and_components/context_menus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int main()
2020
if (dpp::run_once<struct register_bot_commands>()) {
2121
/* Register the command */
2222
bot.guild_command_create(
23-
dpp::slashcommand()
23+
dpp::slashcommand()
2424
.set_type(dpp::ctxm_user)
2525
.set_name("High Five")
2626
.set_application_id(bot.me.id),

docpages/example_programs/interactions_and_components/upload_parameter.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,32 @@ something like `dpp::cluster::request()`.
1212
1313
int main()
1414
{
15-
dpp::cluster bot("token");
15+
dpp::cluster bot("token");
1616
17-
bot.on_log(dpp::utility::cout_logger());
17+
bot.on_log(dpp::utility::cout_logger());
1818
19-
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
20-
if (event.command.type == dpp::it_application_command) {
21-
dpp::command_interaction cmd_data = std::get<dpp::command_interaction>(event.command.data);
22-
if (cmd_data.name == "show") {
23-
dpp::snowflake file_id = std::get<dpp::snowflake>(event.get_parameter("file"));
24-
auto iter = event.command.resolved.attachments.find(file_id);
25-
if (iter != event.command.resolved.attachments.end()) {
26-
const dpp::attachment& att = iter->second;
27-
event.reply(att.url);
28-
}
29-
}
30-
}
31-
});
19+
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
20+
dpp::command_interaction cmd_data = std::get<dpp::command_interaction>(event.command.data);
21+
if (cmd_data.name == "show") {
22+
dpp::snowflake file_id = std::get<dpp::snowflake>(event.get_parameter("file"));
23+
dpp::attachment att = event.command.get_resolved_attachment(file_id);
24+
event.reply(att.url);
25+
}
26+
});
3227
33-
bot.on_ready([&bot](const dpp::ready_t & event) {
28+
bot.on_ready([&bot](const dpp::ready_t & event) {
3429
35-
if (dpp::run_once<struct register_bot_commands>()) {
36-
dpp::slashcommand newcommand("show", "Show an uploaded file", bot.me.id);
30+
if (dpp::run_once<struct register_bot_commands>()) {
31+
dpp::slashcommand newcommand("show", "Show an uploaded file", bot.me.id);
3732
38-
newcommand.add_option(dpp::command_option(dpp::co_attachment, "file", "Select an image"));
33+
newcommand.add_option(dpp::command_option(dpp::co_attachment, "file", "Select an image"));
3934
40-
bot.global_command_create(newcommand);
41-
}
42-
});
35+
bot.global_command_create(newcommand);
36+
}
37+
});
4338
44-
bot.start(dpp::st_wait);
39+
bot.start(dpp::st_wait);
4540
46-
return 0;
41+
return 0;
4742
}
4843
~~~~~~~~~~~~~~~~

include/dpp/appcommand.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ struct DPP_EXPORT interaction_modal_response : public interaction_response, publ
474474
};
475475

476476
/**
477-
* @brief Resolved snowflake ids to users, guild members, roles and channels.
477+
* @brief Resolved snowflake ids to users, guild members, roles and channels. You can use the `interaction::get_resolved_*` methods to easily get a resolved set
478478
*/
479479
struct DPP_EXPORT command_resolved {
480480
/**
@@ -695,7 +695,7 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
695695
user usr; //!< User object for the invoking user
696696
std::string token; //!< a continuation token for responding to the interaction
697697
uint8_t version; //!< read-only property, always 1
698-
command_resolved resolved; //!< Resolved user/role etc
698+
command_resolved resolved; //!< Resolved data e.g. users, members, roles, channels, permissions, etc.
699699
std::string locale; //!< User's [locale](https://discord.com/developers/docs/reference#locales) (language)
700700
std::string guild_locale; //!< Guild's locale (language) - for guild interactions only
701701
cache_policy_t cache_policy; //!< Cache policy from cluster

include/dpp/cluster.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,57 @@ class DPP_EXPORT cluster {
26512651
*/
26522652
void guild_get_vanity(snowflake guild_id, command_completion_event_t callback);
26532653

2654+
/**
2655+
* @brief Get the guild's onboarding configuration
2656+
*
2657+
* @see https://discord.com/developers/docs/resources/guild#get-guild-onboarding
2658+
* @param o The onboarding object
2659+
* @param callback Function to call when the API call completes.
2660+
* On success the callback will contain a dpp::onboarding object in confirmation_callback_t::value filled to match the vanity url. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
2661+
*/
2662+
void guild_get_onboarding(snowflake guild_id, command_completion_event_t callback);
2663+
2664+
/**
2665+
* @brief Edit the guild's onboarding configuration
2666+
*
2667+
* Requires the `MANAGE_GUILD` and `MANAGE_ROLES` permissions.
2668+
*
2669+
* @note Onboarding enforces constraints when enabled. These constraints are that there must be at least 7 Default Channels and at least 5 of them must allow sending messages to the \@everyone role. The `onboarding::mode` field modifies what is considered when enforcing these constraints.
2670+
*
2671+
* @see https://discord.com/developers/docs/resources/guild#modify-guild-onboarding
2672+
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
2673+
* @param o The onboarding object
2674+
* @param callback Function to call when the API call completes.
2675+
* On success the callback will contain a dpp::onboarding object in confirmation_callback_t::value filled to match the vanity url. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
2676+
*/
2677+
void guild_edit_onboarding(const struct onboarding& o, command_completion_event_t callback = utility::log_error());
2678+
2679+
/**
2680+
* @brief Get the guild's welcome screen
2681+
*
2682+
* If the welcome screen is not enabled, the `MANAGE_GUILD` permission is required.
2683+
*
2684+
* @see https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
2685+
* @param guild_id The guild ID to get the welcome screen from
2686+
* @param callback Function to call when the API call completes.
2687+
* On success the callback will contain a dpp::welcome_screen object in confirmation_callback_t::value filled to match the vanity url. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
2688+
*/
2689+
void guild_get_welcome_screen(snowflake guild_id, command_completion_event_t callback);
2690+
2691+
/**
2692+
* @brief Edit the guild's welcome screen
2693+
*
2694+
* Requires the `MANAGE_GUILD` permission. May fire a `Guild Update` Gateway event.
2695+
*
2696+
* @see https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
2697+
* @param guild_id The guild ID to edit the welcome screen for
2698+
* @param welcome_screen The welcome screen
2699+
* @param enabled Whether the welcome screen should be enabled or disabled
2700+
* @param callback Function to call when the API call completes.
2701+
* On success the callback will contain a dpp::welcome_screen object in confirmation_callback_t::value filled to match the vanity url. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
2702+
*/
2703+
void guild_edit_welcome_screen(snowflake guild_id, const struct welcome_screen& welcome_screen, bool enabled, command_completion_event_t callback = utility::log_error());
2704+
26542705
/**
26552706
* @brief Create a webhook
26562707
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.

0 commit comments

Comments
 (0)