Skip to content
Draft
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
129 changes: 123 additions & 6 deletions 3rdParty/dpp/appcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
************************************************************************************/
#pragma once
#include <dpp/integration.h>
#include <dpp/export.h>
#include <dpp/snowflake.h>
#include <dpp/managed.h>
Expand All @@ -39,9 +40,13 @@ namespace dpp {
* This value represents that maximum. interaction_response::add_autocomplete_choice does not allow
* adding more than this number of elements to the vector.
*/
#ifndef AUTOCOMPLETE_MAX_CHOICES
#define AUTOCOMPLETE_MAX_CHOICES 25
#endif
inline constexpr size_t AUTOCOMPLETE_MAX_CHOICES = 25;

/**
* @brief Discords default attachment size limit is 10MiB, and will be used in case
* an interaction does not contain its attachment size limit.
*/
inline constexpr uint32_t DEFAULT_ATTACHMENT_SIZE_LIMIT = 10 * 1024 * 1024;

/**
* @brief Represents command option types.
Expand Down Expand Up @@ -443,6 +448,9 @@ enum interaction_response_type {
* @see https://discord.com/developers/docs/monetization/entitlements#premiumrequired-interaction-response
* @note Not available for autocomplete and ping interactions.
* @warning This response does not support using `content`, `embeds`, or `attachments`, so reply with no data when using this!
*
* @depreciated Replaced with buttons with a style of cos_premium
* This interaction type may stop working at any point
*/
ir_premium_required = 10,
};
Expand Down Expand Up @@ -601,6 +609,36 @@ struct DPP_EXPORT interaction_modal_response : public interaction_response, publ
*/
interaction_modal_response(const std::string& _custom_id, const std::string& _title, const std::vector<component> _components = {});

/**
* @brief Copy constructor
*
* @param other The object to copy from
*/
interaction_modal_response(const interaction_modal_response& other) = default;

/**
* @brief Copy assignment operator
*
* @param other The object to copy from
* @return interaction_modal_response& reference to self
*/
interaction_modal_response& operator=(const interaction_modal_response& other) = default;

/**
* @brief Move constructor
*
* @param other The object to move from
*/
interaction_modal_response(interaction_modal_response&& other) noexcept = default;

/**
* @brief Move assignment operator
*
* @param other The object to move from
* @return interaction_modal_response& reference to self
*/
interaction_modal_response& operator=(interaction_modal_response&& other) noexcept = default;

/**
* @brief Set the custom id
*
Expand Down Expand Up @@ -770,6 +808,26 @@ enum interaction_type {
it_modal_submit = 5,
};

/*
* @brief Context type where the interaction can be used or triggered from, e.g. guild, user etc
*/
enum interaction_context_type {
/**
* @brief Interaction can be used within servers
*/
itc_guild = 0,

/**
* @brief Interaction can be used within DMs with the app's bot user
*/
itc_bot_dm = 1,

/**
* @brief Interaction can be used within Group DMs and DMs other than the app's bot user
*/
itc_private_channel = 2,
};

/**
* @brief Right-click context menu types
*/
Expand Down Expand Up @@ -918,7 +976,7 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
* @brief Get a resolved object from the resolved set
*
* @tparam T type of object to retrieve
* @tparam C container defintion for resolved container
* @tparam C container definition for resolved container
* @param id Snowflake ID
* @param resolved_set container for the type
* @return const T& retrieved type
Expand Down Expand Up @@ -949,6 +1007,16 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
virtual json to_json_impl(bool with_id = false) const;

public:
/**
* @brief Context where the interaction was triggered from
*/
std::map<application_integration_types, snowflake> authorizing_integration_owners;

/**
* @brief Context where the interaction was triggered from
*/
std::optional<interaction_context_type> context;

/**
* @brief ID of the application this interaction is for.
*/
Expand Down Expand Up @@ -1029,6 +1097,11 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
*/
std::string guild_locale;

/**
* @brief Attachment size limit in bytes for this interaction. Will be the discord default if not provided by the interaction.
*/
uint32_t attachment_size_limit;

/**
* @brief Cache policy from cluster.
*/
Expand Down Expand Up @@ -1191,6 +1264,30 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
* is not for a command.
*/
std::string get_command_name() const;

/**
* @brief Get the user who installed the application for a given type.
* @param type Type of installation for the command, e.g. dpp::ait_guild_install or
* dpp::ait_user_install.
* @return The snowflake of the user. In the event this type is not allowed for the
* given command, this will return a default-initialised snowflake with value 0.
*/
dpp::snowflake get_authorizing_integration_owner(application_integration_types type) const;

/**
* @brief Returns true if this interaction occurred as a user-app interaction, e.g.
* within a DM or group DM, added to the user not a guild.
* @return true if a user-app interaction
*/
bool is_user_app_interaction() const;

/**
* @brief Returns true if this interaction occurred as a guild-invited interaction, e.g.
* within a guild's channel, or a DM of a user in that guild.
* @return true if a guild interaction
*/
bool is_guild_interaction() const;

};

/**
Expand Down Expand Up @@ -1417,10 +1514,21 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
*/
permission default_member_permissions;

/**
* @brief Installation contexts where the command is available, only for globally-scoped commands. Defaults to your app's configured contexts
*/
std::vector<application_integration_types> integration_types;

/**
* @brief Interaction context(s) where the command can be used, only for globally-scoped commands. By default, all interaction context types included for new commands.
*/
std::vector<interaction_context_type> contexts;

/**
* @brief True if this command should be allowed in a DM
* D++ defaults this to false. Cannot be set to true in a guild
* command, only a global command.
* @deprecated Use dpp::slashcommand_t::set_interaction_contexts instead
*/
bool dm_permission;

Expand Down Expand Up @@ -1487,7 +1595,8 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
/**
* @brief Set the default permissions of the slash command
*
* @param defaults default permissions to set. This is a permission bitmask of bits from dpp::permissions
* @param defaults default permissions to set. This is a permission bitmask of bits from dpp::permissions.
* This is also an AND list, which means the user must have **all** specified permissions to use the command.
* @note You can set it to 0 to disable the command for everyone except admins by default
*
* @return slashcommand& reference to self for chaining of calls
Expand Down Expand Up @@ -1540,6 +1649,14 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
*/
slashcommand& set_application_id(snowflake i);

/**
* @brief Set the interaction contexts for the command
*
* @param contexts the contexts to set
* @return slashcommand& reference to self for chaining of calls
*/
slashcommand& set_interaction_contexts(std::vector<interaction_context_type> contexts);

/**
* @brief Adds a permission to the command
*
Expand Down Expand Up @@ -1588,4 +1705,4 @@ typedef std::unordered_map<snowflake, slashcommand> slashcommand_map;
*/
typedef std::unordered_map<snowflake, guild_command_permissions> guild_command_permissions_map;

} // namespace dpp
}
55 changes: 54 additions & 1 deletion 3rdParty/dpp/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
************************************************************************************/

#pragma once
#include <dpp/integration.h>
#include <dpp/export.h>
#include <dpp/snowflake.h>
#include <dpp/managed.h>
Expand All @@ -30,6 +31,8 @@
#include <dpp/permissions.h>
#include <dpp/json_fwd.h>
#include <dpp/json_interface.h>
#include <map>
#include <optional>

namespace dpp {

Expand Down Expand Up @@ -209,6 +212,31 @@ class DPP_EXPORT app_team {
snowflake owner_user_id;
};

/**
* @brief Status indicating whether event webhooks are enabled or disabled for an application.
*/
enum application_event_webhook_status: uint8_t {
/**
* @brief Webhook events are disabled by developer
*/
ews_disabled = 1,
/**
* @brief Webhook events are enabled by developer
*/
ews_enabled = 2,
/**
* @brief Webhook events are disabled by Discord, usually due to inactivity
*/
ews_disabled_by_discord = 3,
};

/**
* @brief Configuration object for an app installation
*/
struct DPP_EXPORT integration_configuration {
application_install_params oauth2_install_params;
};

/**
* @brief The application class represents details of a bot application
*/
Expand Down Expand Up @@ -325,6 +353,11 @@ class DPP_EXPORT application : public managed, public json_interface<application
*/
uint64_t approximate_guild_count;

/**
* @brief Optional: Approximate count of users that have installed the app
*/
uint64_t approximate_user_install_count;

/**
* @brief Optional: Array of redirect URIs for the app.
*/
Expand All @@ -342,6 +375,21 @@ class DPP_EXPORT application : public managed, public json_interface<application
*/
std::string role_connections_verification_url;

/**
* @brief Event webhooks URL for the app to receive webhook events
*/
std::string event_webhooks_url;

/**
* @brief List of Webhook event types the app subscribes to.
*/
std::vector<std::string> event_webhooks_types;

/**
* If webhook events are enabled for the app.
*/
application_event_webhook_status event_webhooks_status;

/**
* @brief Up to 5 tags describing the content and functionality of the application.
*/
Expand All @@ -352,6 +400,11 @@ class DPP_EXPORT application : public managed, public json_interface<application
*/
application_install_params install_params;

/**
* @brief Default scopes and permissions for each supported installation context
*/
std::map<application_integration_types, integration_configuration> integration_types_config;

/**
* @brief The application's default custom authorization link, if enabled.
*/
Expand Down Expand Up @@ -467,4 +520,4 @@ class DPP_EXPORT application : public managed, public json_interface<application
*/
typedef std::unordered_map<snowflake, application> application_map;

} // namespace dpp
}
2 changes: 1 addition & 1 deletion 3rdParty/dpp/auditlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,4 @@ class DPP_EXPORT auditlog : public json_interface<auditlog> {
virtual ~auditlog() = default;
};

} // namespace dpp
}
2 changes: 1 addition & 1 deletion 3rdParty/dpp/automod.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,4 @@ class DPP_EXPORT automod_rule : public managed, public json_interface<automod_ru
*/
typedef std::unordered_map<snowflake, automod_rule> automod_rule_map;

} // namespace dpp
}
2 changes: 1 addition & 1 deletion 3rdParty/dpp/ban.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ class DPP_EXPORT ban : public json_interface<ban> {
*/
typedef std::unordered_map<snowflake, ban> ban_map;

} // namespace dpp
}
Loading