diff --git a/src/builder/create_command.rs b/src/builder/create_command.rs index 7f7da383a5b..c32795f8d39 100644 --- a/src/builder/create_command.rs +++ b/src/builder/create_command.rs @@ -318,6 +318,8 @@ pub struct CreateCommand { #[serde(skip_serializing_if = "Option::is_none")] contexts: Option>, nsfw: bool, + #[serde(skip_serializing_if = "Option::is_none")] + handler: Option, } impl CreateCommand { @@ -338,6 +340,7 @@ impl CreateCommand { options: Vec::new(), nsfw: false, + handler: None, } } @@ -455,6 +458,15 @@ impl CreateCommand { self.nsfw = nsfw; self } + + /// Sets the command's entry point handler type. Only valid for commands of type + /// [`PrimaryEntryPoint`]. + /// + /// [`PrimaryEntryPoint`]: CommandType::PrimaryEntryPoint + pub fn handler(mut self, handler: EntryPointHandlerType) -> Self { + self.handler = Some(handler); + self + } } #[cfg(feature = "http")] diff --git a/src/builder/create_interaction_response.rs b/src/builder/create_interaction_response.rs index 13809de512d..5e77281d06c 100644 --- a/src/builder/create_interaction_response.rs +++ b/src/builder/create_interaction_response.rs @@ -66,6 +66,13 @@ pub enum CreateInteractionResponse { /// Corresponds to Discord's `PREMIUM_REQUIRED'. #[deprecated = "use premium button components via `CreateButton::new_premium` instead"] PremiumRequired, + /// Not valid for autocomplete and Ping interactions. Only available for applications with + /// Activities enabled. + /// + /// Responds to the interaction by launching the Activity associated with the app. + /// + /// Corresponds to Discord's `LAUNCH_ACTIVITY`. + LaunchActivity, } impl serde::Serialize for CreateInteractionResponse { @@ -83,6 +90,7 @@ impl serde::Serialize for CreateInteractionResponse { Self::Autocomplete(_) => 8, Self::Modal(_) => 9, Self::PremiumRequired => 10, + Self::LaunchActivity => 12, })?; match self { @@ -94,6 +102,7 @@ impl serde::Serialize for CreateInteractionResponse { Self::Autocomplete(x) => map.serialize_entry("data", &x)?, Self::Modal(x) => map.serialize_entry("data", &x)?, Self::PremiumRequired => map.serialize_entry("data", &None::<()>)?, + Self::LaunchActivity => map.serialize_entry("data", &None::<()>)?, } map.end() diff --git a/src/model/application/command.rs b/src/model/application/command.rs index 5bb6e891d5e..6c8525a5cab 100644 --- a/src/model/application/command.rs +++ b/src/model/application/command.rs @@ -94,6 +94,10 @@ pub struct Command { pub contexts: Option>, /// An autoincremented version identifier updated during substantial record changes. pub version: CommandVersionId, + /// Only present for commands of type [`PrimaryEntryPoint`]. + /// + /// [`PrimaryEntryPoint`]: CommandType::PrimaryEntryPoint + pub handler: Option, } #[cfg(feature = "model")] @@ -242,6 +246,23 @@ enum_number! { ChatInput = 1, User = 2, Message = 3, + PrimaryEntryPoint = 4, + _ => Unknown(u8), + } +} + +enum_number! { + /// Signifies how the invocation of a command of type [`PrimaryEntryPoint`] should be handled. + /// + /// [`PrimaryEntryPoint`]: CommandType::PrimaryEntryPoint + /// [Discord docs](https://discord.com/developers/docs/interactions/application-commands#application-command-object-entry-point-command-handler-types) + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)] + #[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))] + #[serde(from = "u8", into = "u8")] + #[non_exhaustive] + pub enum EntryPointHandlerType { + AppHandler = 1, + DiscordLaunchActivity = 2, _ => Unknown(u8), } }