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
15 changes: 12 additions & 3 deletions include/dpp/appcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,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 @@ -1093,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
7 changes: 6 additions & 1 deletion src/dpp/slashcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ slashcommand& slashcommand::add_option(const command_option &o)
return *this;
}

interaction::interaction() : application_id(0), type(0), guild_id(0), channel_id(0), message_id(0), version(0), cache_policy(cache_policy::cpol_default) {
interaction::interaction() : application_id(0), type(0), guild_id(0), channel_id(0), message_id(0), version(0), attachment_size_limit(DEFAULT_ATTACHMENT_SIZE_LIMIT), cache_policy(cache_policy::cpol_default) {
}

command_interaction interaction::get_command_interaction() const {
Expand Down Expand Up @@ -625,6 +625,11 @@ void from_json(const nlohmann::json& j, interaction& i) {
i.channel_id = snowflake_not_null(&j, "channel_id");
i.guild_id = snowflake_not_null(&j, "guild_id");
i.app_permissions = snowflake_not_null(&j, "app_permissions");
i.attachment_size_limit = int32_not_null(&j, "attachment_size_limit");

if (i.attachment_size_limit == 0) {
i.attachment_size_limit = DEFAULT_ATTACHMENT_SIZE_LIMIT;
}

if (j.contains("channel") && !j.at("channel").is_null()) {
const json& c = j["channel"];
Expand Down