Skip to content
Merged
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
59 changes: 57 additions & 2 deletions include/dpp/cluster_coro_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,61 @@ awaitable<confirmation_callback_t> co_guild_set_nickname(snowflake guild_id, con
*/
awaitable<confirmation_callback_t> co_guild_sync_integration(snowflake guild_id, snowflake integration_id);

/**
* @brief Get the guild's onboarding configuration
*
* @see dpp::cluster::guild_get_onboarding
* @see https://discord.com/developers/docs/resources/guild#get-guild-onboarding
* @param o The onboarding object
* @return onboarding returned object on completion
* \memberof dpp::cluster
*/
awaitable<confirmation_callback_t> co_guild_get_onboarding(snowflake guild_id);

/**
* @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 dpp::cluster::guild_edit_onboarding
* @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
* @return onboarding returned object on completion
* \memberof dpp::cluster
*/
awaitable<confirmation_callback_t> co_guild_edit_onboarding(const struct onboarding& o);

/**
* @brief Get the guild's welcome screen
*
* If the welcome screen is not enabled, the `MANAGE_GUILD` permission is required.
*
* @see dpp::cluster::guild_get_welcome_screen
* @see https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
* @param guild_id The guild ID to get the welcome screen from
* @return dpp::welcome_screen returned object on completion
* \memberof dpp::cluster
*/
awaitable<confirmation_callback_t> co_guild_get_welcome_screen(snowflake guild_id);

/**
* @brief Edit the guild's welcome screen
*
* Requires the `MANAGE_GUILD` permission. May fire a `Guild Update` Gateway event.
*
* @see dpp::cluster::guild_edit_welcome_screen
* @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
* @return dpp::welcome_screen returned object on completion
* \memberof dpp::cluster
*/
awaitable<confirmation_callback_t> co_guild_edit_welcome_screen(snowflake guild_id, const struct welcome_screen& welcome_screen, bool enabled);

/**
* @brief Add guild member. Needs a specific oauth2 scope, from which you get the access_token.
*
Expand Down Expand Up @@ -1883,7 +1938,7 @@ awaitable<confirmation_callback_t> co_threads_get_joined_private_archived(snowfl
* @see dpp::cluster::threads_get_private_archived
* @see https://discord.com/developers/docs/resources/channel#list-private-archived-threads
* @param channel_id Channel to get public archived threads for
* @param before_timestamp Get threads before this timestamp
* @param before_timestamp Get threads archived before this timestamp
* @param limit Number of threads to get
* @return thread_map returned object on completion
* \memberof dpp::cluster
Expand All @@ -1895,7 +1950,7 @@ awaitable<confirmation_callback_t> co_threads_get_private_archived(snowflake cha
* @see dpp::cluster::threads_get_public_archived
* @see https://discord.com/developers/docs/resources/channel#list-public-archived-threads
* @param channel_id Channel to get public archived threads for
* @param before_timestamp Get threads before this timestamp
* @param before_timestamp Get threads archived before this timestamp
* @param limit Number of threads to get
* @return thread_map returned object on completion
* \memberof dpp::cluster
Expand Down
71 changes: 69 additions & 2 deletions include/dpp/cluster_sync_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,73 @@ confirmation guild_set_nickname_sync(snowflake guild_id, const std::string &nick
*/
confirmation guild_sync_integration_sync(snowflake guild_id, snowflake integration_id);

/**
* @brief Get the guild's onboarding configuration
*
* @see dpp::cluster::guild_get_onboarding
* @see https://discord.com/developers/docs/resources/guild#get-guild-onboarding
* @param o The onboarding object
* @return onboarding returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
onboarding guild_get_onboarding_sync(snowflake guild_id);

/**
* @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 dpp::cluster::guild_edit_onboarding
* @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
* @return onboarding returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
onboarding guild_edit_onboarding_sync(const struct onboarding& o);

/**
* @brief Get the guild's welcome screen
*
* If the welcome screen is not enabled, the `MANAGE_GUILD` permission is required.
*
* @see dpp::cluster::guild_get_welcome_screen
* @see https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
* @param guild_id The guild ID to get the welcome screen from
* @return dpp::welcome_screen returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
dpp::welcome_screen guild_get_welcome_screen_sync(snowflake guild_id);

/**
* @brief Edit the guild's welcome screen
*
* Requires the `MANAGE_GUILD` permission. May fire a `Guild Update` Gateway event.
*
* @see dpp::cluster::guild_edit_welcome_screen
* @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
* @return dpp::welcome_screen returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
dpp::welcome_screen guild_edit_welcome_screen_sync(snowflake guild_id, const struct welcome_screen& welcome_screen, bool enabled);

/**
* @brief Add guild member. Needs a specific oauth2 scope, from which you get the access_token.
*
Expand Down Expand Up @@ -2315,7 +2382,7 @@ thread_map threads_get_joined_private_archived_sync(snowflake channel_id, snowfl
* @see dpp::cluster::threads_get_private_archived
* @see https://discord.com/developers/docs/resources/channel#list-private-archived-threads
* @param channel_id Channel to get public archived threads for
* @param before_timestamp Get threads before this timestamp
* @param before_timestamp Get threads archived before this timestamp
* @param limit Number of threads to get
* @return thread_map returned object on completion
* \memberof dpp::cluster
Expand All @@ -2330,7 +2397,7 @@ thread_map threads_get_private_archived_sync(snowflake channel_id, time_t befor
* @see dpp::cluster::threads_get_public_archived
* @see https://discord.com/developers/docs/resources/channel#list-public-archived-threads
* @param channel_id Channel to get public archived threads for
* @param before_timestamp Get threads before this timestamp
* @param before_timestamp Get threads archived before this timestamp
* @param limit Number of threads to get
* @return thread_map returned object on completion
* \memberof dpp::cluster
Expand Down
13 changes: 12 additions & 1 deletion include/dpp/unicode_emoji.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#pragma once

namespace dpp { namespace unicode_emoji {
namespace dpp {

/**
* The unicode emojis in this namespace are auto-generated from https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json
*
* 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 {
constexpr const char[] _100 = "💯";
constexpr const char[] _1234 = "🔢";
constexpr const char[] soccer = "⚽";
Expand Down
16 changes: 16 additions & 0 deletions src/dpp/cluster_coro_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,22 @@ awaitable<confirmation_callback_t> cluster::co_guild_sync_integration(snowflake
return {this, static_cast<void (cluster::*)(snowflake, snowflake, command_completion_event_t)>(&cluster::guild_sync_integration), guild_id, integration_id};
}

awaitable<confirmation_callback_t> cluster::co_guild_get_onboarding(snowflake guild_id) {
return {this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::guild_get_onboarding), guild_id};
}

awaitable<confirmation_callback_t> cluster::co_guild_edit_onboarding(const struct onboarding& o) {
return {this, static_cast<void (cluster::*)(const struct onboarding&, command_completion_event_t)>(&cluster::guild_edit_onboarding), o};
}

awaitable<confirmation_callback_t> cluster::co_guild_get_welcome_screen(snowflake guild_id) {
return {this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::guild_get_welcome_screen), guild_id};
}

awaitable<confirmation_callback_t> cluster::co_guild_edit_welcome_screen(snowflake guild_id, const struct welcome_screen& welcome_screen, bool enabled) {
return {this, static_cast<void (cluster::*)(snowflake, const struct welcome_screen&, bool, command_completion_event_t)>(&cluster::guild_edit_welcome_screen), guild_id, welcome_screen, enabled};
}

awaitable<confirmation_callback_t> cluster::co_guild_add_member(const guild_member& gm, const std::string &access_token) {
return {this, static_cast<void (cluster::*)(const guild_member&, const std::string &, command_completion_event_t)>(&cluster::guild_add_member), gm, access_token};
}
Expand Down
16 changes: 16 additions & 0 deletions src/dpp/cluster_sync_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@ confirmation cluster::guild_sync_integration_sync(snowflake guild_id, snowflake
return dpp::sync<confirmation>(this, static_cast<void (cluster::*)(snowflake, snowflake, command_completion_event_t)>(&cluster::guild_sync_integration), guild_id, integration_id);
}

onboarding cluster::guild_get_onboarding_sync(snowflake guild_id) {
return dpp::sync<onboarding>(this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::guild_get_onboarding), guild_id);
}

onboarding cluster::guild_edit_onboarding_sync(const struct onboarding& o) {
return dpp::sync<onboarding>(this, static_cast<void (cluster::*)(const struct onboarding&, command_completion_event_t)>(&cluster::guild_edit_onboarding), o);
}

dpp::welcome_screen cluster::guild_get_welcome_screen_sync(snowflake guild_id) {
return dpp::sync<dpp::welcome_screen>(this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::guild_get_welcome_screen), guild_id);
}

dpp::welcome_screen cluster::guild_edit_welcome_screen_sync(snowflake guild_id, const struct welcome_screen& welcome_screen, bool enabled) {
return dpp::sync<dpp::welcome_screen>(this, static_cast<void (cluster::*)(snowflake, const struct welcome_screen&, bool, command_completion_event_t)>(&cluster::guild_edit_welcome_screen), guild_id, welcome_screen, enabled);
}

confirmation cluster::guild_add_member_sync(const guild_member& gm, const std::string &access_token) {
return dpp::sync<confirmation>(this, static_cast<void (cluster::*)(const guild_member&, const std::string &, command_completion_event_t)>(&cluster::guild_add_member), gm, access_token);
}
Expand Down
6 changes: 3 additions & 3 deletions src/unittest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,11 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
}
set_test("MESSAGEPIN", false);
set_test("MESSAGEUNPIN", false);
bot.message_pin(channel_id, message_id, [=](const dpp::confirmation_callback_t &callback) {
bot.message_pin(channel_id, message_id, [this](const dpp::confirmation_callback_t &callback) {
std::lock_guard lock(mutex);
if (!callback.is_error()) {
set_test("MESSAGEPIN", true);
bot.message_unpin(TEST_TEXT_CHANNEL_ID, message_id, [=](const dpp::confirmation_callback_t &callback) {
bot.message_unpin(TEST_TEXT_CHANNEL_ID, message_id, [this](const dpp::confirmation_callback_t &callback) {
std::lock_guard lock(mutex);
if (!callback.is_error()) {
set_test("MESSAGEUNPIN", true);
Expand Down Expand Up @@ -973,7 +973,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
set_test("THREAD_UPDATE_EVENT", false);
edit.name = "edited";
edit.metadata.locked = true;
bot.thread_edit(edit, [this, id = edit.id](const dpp::confirmation_callback_t &callback) {
bot.thread_edit(edit, [this](const dpp::confirmation_callback_t &callback) {
std::lock_guard lock(mutex);
if (!callback.is_error()) {
set_test("THREAD_EDIT", true);
Expand Down