diff --git a/interactions.go b/interactions.go index c562463..9ef83ed 100644 --- a/interactions.go +++ b/interactions.go @@ -38,12 +38,17 @@ type ApplicationCommand struct { Type ApplicationCommandType `json:"type,omitempty"` Name string `json:"name"` NameLocalizations *map[Locale]string `json:"name_localizations,omitempty"` - // NOTE: DefaultPermission will be soon deprecated. Use DefaultMemberPermissions and DMPermission instead. + + // NOTE: DefaultPermission will be soon deprecated. Use DefaultMemberPermissions and Contexts instead. DefaultPermission *bool `json:"default_permission,omitempty"` DefaultMemberPermissions *int64 `json:"default_member_permissions,string,omitempty"` - DMPermission *bool `json:"dm_permission,omitempty"` NSFW *bool `json:"nsfw,omitempty"` + // Deprecated: use Contexts instead. + DMPermission *bool `json:"dm_permission,omitempty"` + Contexts *[]InteractionContextType `json:"contexts,omitempty"` + IntegrationTypes *[]ApplicationIntegrationType `json:"integration_types,omitempty"` + // NOTE: Chat commands only. Otherwise it mustn't be set. Description string `json:"description,omitempty"` @@ -200,6 +205,18 @@ func (t InteractionType) String() string { return fmt.Sprintf("InteractionType(%d)", t) } +// InteractionContextType represents the context in which interaction can be used or was triggered from. +type InteractionContextType uint + +const ( + // InteractionContextGuild indicates that interaction can be used within guilds. + InteractionContextGuild InteractionContextType = 0 + // InteractionContextBotDM indicates that interaction can be used within DMs with the bot. + InteractionContextBotDM InteractionContextType = 1 + // InteractionContextPrivateChannel indicates that interaction can be used within group DMs and DMs with other users. + InteractionContextPrivateChannel InteractionContextType = 2 +) + // Interaction represents data of an interaction. type Interaction struct { ID string `json:"id"` @@ -233,6 +250,9 @@ type Interaction struct { // NOTE: this field is only filled when the interaction was invoked in a guild. GuildLocale *Locale `json:"guild_locale"` + Context InteractionContextType `json:"context"` + AuthorizingIntegrationOwners map[ApplicationIntegrationType]string `json:"authorizing_integration_owners"` + Token string `json:"token"` Version int `json:"version"` } diff --git a/message.go b/message.go index 3b03ed5..5f549df 100644 --- a/message.go +++ b/message.go @@ -135,11 +135,14 @@ type Message struct { // If the field exists but is null, the referenced message was deleted. ReferencedMessage *Message `json:"referenced_message"` + // Deprecated, use InteractionMetadata. // Is sent when the message is a response to an Interaction, without an existing message. // This means responses to message component interactions do not include this property, // instead including a MessageReference, as components exist on preexisting messages. Interaction *MessageInteraction `json:"interaction"` + InteractionMetadata *MessageInteractionMetadata `json:"interaction_metadata"` + // The flags of the message, which describe extra features of a message. // This is a combination of bit masks; the presence of a certain permission can // be checked by performing a bitwise AND between this int and the flag. @@ -567,3 +570,24 @@ type MessageInteraction struct { // Member is only present when the interaction is from a guild. Member *Member `json:"member"` } + +// MessageInteractionMetadata contains metadata of an interaction, including relevant user info. +type MessageInteractionMetadata struct { + // ID of the interaction. + ID string `json:"id"` + // Type of the interaction. + Type InteractionType `json:"type"` + // User who triggered the interaction. + User *User `json:"user"` + // IDs for installation context(s) related to an interaction. + AuthorizingIntegrationOwners map[ApplicationIntegrationType]string `json:"authorizing_integration_owners"` + // ID of the original response message. + // NOTE: present only on followup messages. + OriginalResponseMessageID string `json:"original_response_message_id,omitempty"` + // ID of the message that contained interactive component. + // NOTE: present only on message component interactions. + InteractedMessageID string `json:"interacted_message_id,omitempty"` + // Metadata for interaction that was used to open a modal. + // NOTE: present only on modal submit interactions. + TriggeringInteractionMetadata *MessageInteractionMetadata `json:"triggering_interaction_metadata,omitempty"` +} diff --git a/structs.go b/structs.go index b7e0297..09fddc7 100644 --- a/structs.go +++ b/structs.go @@ -136,26 +136,49 @@ type Session struct { wsMutex sync.Mutex } +// ApplicationIntegrationType dictates where application can be installed and its available interaction contexts. +type ApplicationIntegrationType uint + +const ( + // ApplicationIntegrationGuildInstall indicates that app is installable to guilds. + ApplicationIntegrationGuildInstall ApplicationIntegrationType = 0 + // ApplicationIntegrationUserInstall indicates that app is installable to users. + ApplicationIntegrationUserInstall ApplicationIntegrationType = 1 +) + +// ApplicationInstallParams represents application's installation parameters +// for default in-app oauth2 authorization link. +type ApplicationInstallParams struct { + Scopes []string `json:"scopes"` + Permissions int64 `json:"permissions,string"` +} + +// ApplicationIntegrationTypeConfig represents application's configuration for a particular integration type. +type ApplicationIntegrationTypeConfig struct { + OAuth2InstallParams *ApplicationInstallParams `json:"oauth2_install_params,omitempty"` +} + // Application stores values for a Discord Application type Application struct { - ID string `json:"id,omitempty"` - Name string `json:"name"` - Icon string `json:"icon,omitempty"` - Description string `json:"description,omitempty"` - RPCOrigins []string `json:"rpc_origins,omitempty"` - BotPublic bool `json:"bot_public,omitempty"` - BotRequireCodeGrant bool `json:"bot_require_code_grant,omitempty"` - TermsOfServiceURL string `json:"terms_of_service_url"` - PrivacyProxyURL string `json:"privacy_policy_url"` - Owner *User `json:"owner"` - Summary string `json:"summary"` - VerifyKey string `json:"verify_key"` - Team *Team `json:"team"` - GuildID string `json:"guild_id"` - PrimarySKUID string `json:"primary_sku_id"` - Slug string `json:"slug"` - CoverImage string `json:"cover_image"` - Flags int `json:"flags,omitempty"` + ID string `json:"id,omitempty"` + Name string `json:"name"` + Icon string `json:"icon,omitempty"` + Description string `json:"description,omitempty"` + RPCOrigins []string `json:"rpc_origins,omitempty"` + BotPublic bool `json:"bot_public,omitempty"` + BotRequireCodeGrant bool `json:"bot_require_code_grant,omitempty"` + TermsOfServiceURL string `json:"terms_of_service_url"` + PrivacyProxyURL string `json:"privacy_policy_url"` + Owner *User `json:"owner"` + Summary string `json:"summary"` + VerifyKey string `json:"verify_key"` + Team *Team `json:"team"` + GuildID string `json:"guild_id"` + PrimarySKUID string `json:"primary_sku_id"` + Slug string `json:"slug"` + CoverImage string `json:"cover_image"` + Flags int `json:"flags,omitempty"` + IntegrationTypesConfig map[ApplicationIntegrationType]*ApplicationIntegrationTypeConfig `json:"integration_types,omitempty"` } // ApplicationRoleConnectionMetadataType represents the type of application role connection metadata.