Skip to content

Commit

Permalink
feat: added functionality for guild onboarding and welcome screen (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil authored Jul 24, 2023
1 parent b3cd632 commit 9b2e5cd
Show file tree
Hide file tree
Showing 6 changed files with 647 additions and 26 deletions.
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

0 comments on commit 9b2e5cd

Please sign in to comment.