From b2cb848c35c71d0905b07b7a10bdf19caf65195b Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Wed, 26 Jul 2023 08:24:59 +0000 Subject: [PATCH] fix: warning for [=] copy without explkit , rerun coro builder for onboarding --- include/dpp/cluster_coro_calls.h | 59 +++++++++++++++++++++++++- include/dpp/cluster_sync_calls.h | 71 +++++++++++++++++++++++++++++++- include/dpp/unicode_emoji.h | 13 +++++- src/dpp/cluster_coro_calls.cpp | 16 +++++++ src/dpp/cluster_sync_calls.cpp | 16 +++++++ src/unittest/test.cpp | 6 +-- 6 files changed, 173 insertions(+), 8 deletions(-) diff --git a/include/dpp/cluster_coro_calls.h b/include/dpp/cluster_coro_calls.h index 0083de91f3..b09d1a979c 100644 --- a/include/dpp/cluster_coro_calls.h +++ b/include/dpp/cluster_coro_calls.h @@ -982,6 +982,61 @@ awaitable co_guild_set_nickname(snowflake guild_id, con */ awaitable 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 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 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 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 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. * @@ -1883,7 +1938,7 @@ awaitable 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 @@ -1895,7 +1950,7 @@ awaitable 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 diff --git a/include/dpp/cluster_sync_calls.h b/include/dpp/cluster_sync_calls.h index 25c89f9fd9..7a61f38d5f 100644 --- a/include/dpp/cluster_sync_calls.h +++ b/include/dpp/cluster_sync_calls.h @@ -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. * @@ -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 @@ -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 diff --git a/include/dpp/unicode_emoji.h b/include/dpp/unicode_emoji.h index b09a5bfb30..2785f8cd53 100644 --- a/include/dpp/unicode_emoji.h +++ b/include/dpp/unicode_emoji.h @@ -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 + * #include + * ``` + */ +namespace unicode_emoji { constexpr const char[] _100 = "💯"; constexpr const char[] _1234 = "🔢"; constexpr const char[] soccer = "⚽"; diff --git a/src/dpp/cluster_coro_calls.cpp b/src/dpp/cluster_coro_calls.cpp index 5eea1a0bc4..9b0d46816a 100644 --- a/src/dpp/cluster_coro_calls.cpp +++ b/src/dpp/cluster_coro_calls.cpp @@ -339,6 +339,22 @@ awaitable cluster::co_guild_sync_integration(snowflake return {this, static_cast(&cluster::guild_sync_integration), guild_id, integration_id}; } +awaitable cluster::co_guild_get_onboarding(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_onboarding), guild_id}; +} + +awaitable cluster::co_guild_edit_onboarding(const struct onboarding& o) { + return {this, static_cast(&cluster::guild_edit_onboarding), o}; +} + +awaitable cluster::co_guild_get_welcome_screen(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_welcome_screen), guild_id}; +} + +awaitable cluster::co_guild_edit_welcome_screen(snowflake guild_id, const struct welcome_screen& welcome_screen, bool enabled) { + return {this, static_cast(&cluster::guild_edit_welcome_screen), guild_id, welcome_screen, enabled}; +} + awaitable cluster::co_guild_add_member(const guild_member& gm, const std::string &access_token) { return {this, static_cast(&cluster::guild_add_member), gm, access_token}; } diff --git a/src/dpp/cluster_sync_calls.cpp b/src/dpp/cluster_sync_calls.cpp index 1ff073cb7a..2b9be8b862 100644 --- a/src/dpp/cluster_sync_calls.cpp +++ b/src/dpp/cluster_sync_calls.cpp @@ -337,6 +337,22 @@ confirmation cluster::guild_sync_integration_sync(snowflake guild_id, snowflake return dpp::sync(this, static_cast(&cluster::guild_sync_integration), guild_id, integration_id); } +onboarding cluster::guild_get_onboarding_sync(snowflake guild_id) { + return dpp::sync(this, static_cast(&cluster::guild_get_onboarding), guild_id); +} + +onboarding cluster::guild_edit_onboarding_sync(const struct onboarding& o) { + return dpp::sync(this, static_cast(&cluster::guild_edit_onboarding), o); +} + +dpp::welcome_screen cluster::guild_get_welcome_screen_sync(snowflake guild_id) { + return dpp::sync(this, static_cast(&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(this, static_cast(&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(this, static_cast(&cluster::guild_add_member), gm, access_token); } diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index bd391f2bae..14bd314ea0 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -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); @@ -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);