Skip to content
Merged

Dev #97

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
33 changes: 33 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,46 @@
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Debug-Coro",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DDPP_CORO=on",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release-Coro",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DDPP_CORO=on",
"buildCommandArgs": "",
"ctestCommandArgs": ""
}
]
}
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ When contributing to this repository, please do not feel intimidated! We welcome
including indent style etc).
7. Your PR must pass the CI actions before being allowed to be merged. Our PR actions check that the
build will compile on various platforms before release and makes precompiled versions of the library.
8. If you are on the discord server for the project and your PR is accepted, let a moderator know and we
will grant you the 'Contributors' role.

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.
22 changes: 20 additions & 2 deletions buildtools/emojis.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@

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

$header = "#pragma once\n\nnamespace dpp { namespace unicode_emoji {\n";
$url = "https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json";

$header = <<<END
#pragma once

namespace dpp {

/**
* The unicode emojis in this namespace are auto-generated from {$url}
*
* If you want to use this, you have to pull the header in separately. e.g.
* ```cpp
* #include <dpp/dpp.h>
* #include <dpp/unicode_emoji.h>
* ```
*/
namespace unicode_emoji {

END;

/* This JSON is generated originally via the NPM package maintained by Discord themselves at https://www.npmjs.com/package/discord-emoji */
$emojis = json_decode(file_get_contents("https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json"));
$emojis = json_decode(file_get_contents($url));
if ($emojis) {
foreach ($emojis as $name=>$code) {
if (preg_match("/^\d+/", $name)) {
Expand Down
7 changes: 7 additions & 0 deletions docpages/05_deprecated_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\page deprecated Deprecated List

### Deprecation policy

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.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main()
if (dpp::run_once<struct register_bot_commands>()) {
/* Register the command */
bot.guild_command_create(
dpp::slashcommand()
dpp::slashcommand()
.set_type(dpp::ctxm_user)
.set_name("High Five")
.set_application_id(bot.me.id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,32 @@ something like `dpp::cluster::request()`.

int main()
{
dpp::cluster bot("token");
dpp::cluster bot("token");

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

bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
if (event.command.type == dpp::it_application_command) {
dpp::command_interaction cmd_data = std::get<dpp::command_interaction>(event.command.data);
if (cmd_data.name == "show") {
dpp::snowflake file_id = std::get<dpp::snowflake>(event.get_parameter("file"));
auto iter = event.command.resolved.attachments.find(file_id);
if (iter != event.command.resolved.attachments.end()) {
const dpp::attachment& att = iter->second;
event.reply(att.url);
}
}
}
});
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
dpp::command_interaction cmd_data = std::get<dpp::command_interaction>(event.command.data);
if (cmd_data.name == "show") {
dpp::snowflake file_id = std::get<dpp::snowflake>(event.get_parameter("file"));
dpp::attachment att = event.command.get_resolved_attachment(file_id);
event.reply(att.url);
}
});

bot.on_ready([&bot](const dpp::ready_t & event) {
bot.on_ready([&bot](const dpp::ready_t & event) {

if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand newcommand("show", "Show an uploaded file", bot.me.id);
if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand newcommand("show", "Show an uploaded file", bot.me.id);

newcommand.add_option(dpp::command_option(dpp::co_attachment, "file", "Select an image"));
newcommand.add_option(dpp::command_option(dpp::co_attachment, "file", "Select an image"));

bot.global_command_create(newcommand);
}
});
bot.global_command_create(newcommand);
}
});

bot.start(dpp::st_wait);
bot.start(dpp::st_wait);

return 0;
return 0;
}
~~~~~~~~~~~~~~~~
4 changes: 2 additions & 2 deletions include/dpp/appcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ struct DPP_EXPORT interaction_modal_response : public interaction_response, publ
};

/**
* @brief Resolved snowflake ids to users, guild members, roles and channels.
* @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
*/
struct DPP_EXPORT command_resolved {
/**
Expand Down Expand Up @@ -695,7 +695,7 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
user usr; //!< User object for the invoking user
std::string token; //!< a continuation token for responding to the interaction
uint8_t version; //!< read-only property, always 1
command_resolved resolved; //!< Resolved user/role etc
command_resolved resolved; //!< Resolved data e.g. users, members, roles, channels, permissions, etc.
std::string locale; //!< User's [locale](https://discord.com/developers/docs/reference#locales) (language)
std::string guild_locale; //!< Guild's locale (language) - for guild interactions only
cache_policy_t cache_policy; //!< Cache policy from cluster
Expand Down
51 changes: 51 additions & 0 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -2651,6 +2651,57 @@ class DPP_EXPORT cluster {
*/
void guild_get_vanity(snowflake guild_id, command_completion_event_t callback);

/**
* @brief Get the guild's onboarding configuration
*
* @see https://discord.com/developers/docs/resources/guild#get-guild-onboarding
* @param o The onboarding object
* @param callback Function to call when the API call completes.
* 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().
*/
void guild_get_onboarding(snowflake guild_id, command_completion_event_t callback);

/**
* @brief Edit the guild's onboarding configuration
*
* Requires the `MANAGE_GUILD` and `MANAGE_ROLES` permissions.
*
* @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.
*
* @see https://discord.com/developers/docs/resources/guild#modify-guild-onboarding
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param o The onboarding object
* @param callback Function to call when the API call completes.
* 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().
*/
void guild_edit_onboarding(const struct onboarding& o, command_completion_event_t callback = utility::log_error());

/**
* @brief Get the guild's welcome screen
*
* If the welcome screen is not enabled, the `MANAGE_GUILD` permission is required.
*
* @see https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
* @param guild_id The guild ID to get the welcome screen from
* @param callback Function to call when the API call completes.
* 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().
*/
void guild_get_welcome_screen(snowflake guild_id, command_completion_event_t callback);

/**
* @brief Edit the guild's welcome screen
*
* Requires the `MANAGE_GUILD` permission. May fire a `Guild Update` Gateway event.
*
* @see https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
* @param guild_id The guild ID to edit the welcome screen for
* @param welcome_screen The welcome screen
* @param enabled Whether the welcome screen should be enabled or disabled
* @param callback Function to call when the API call completes.
* 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().
*/
void guild_edit_welcome_screen(snowflake guild_id, const struct welcome_screen& welcome_screen, bool enabled, command_completion_event_t callback = utility::log_error());

/**
* @brief Create a webhook
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
Expand Down
Loading