From 7b744a24c9279d0959427732eb719aab230d1968 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Tue, 19 Mar 2024 02:00:33 +0300 Subject: [PATCH 01/17] feat: add integration types --- structs.go | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/structs.go b/structs.go index 4df8bd5e4..112436c02 100644 --- a/structs.go +++ b/structs.go @@ -136,26 +136,33 @@ type Session struct { wsMutex sync.Mutex } +type ApplicationIntegrationType uint + +const ( + ApplicationIntegrationGuildInstall ApplicationIntegrationType = 0 + ApplicationIntegrationUserInstall ApplicationIntegrationType = 1 +) + // 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"` } // ApplicationRoleConnectionMetadataType represents the type of application role connection metadata. From 9b0cf706c573d8867e8a5f2ab7fa46d1fcc0979d Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Tue, 19 Mar 2024 02:01:35 +0300 Subject: [PATCH 02/17] feat(ApplicationCommand): add integration_types --- interactions.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interactions.go b/interactions.go index c562463af..5aef4bb4c 100644 --- a/interactions.go +++ b/interactions.go @@ -44,6 +44,8 @@ type ApplicationCommand struct { DMPermission *bool `json:"dm_permission,omitempty"` NSFW *bool `json:"nsfw,omitempty"` + IntegrationTypes *[]ApplicationIntegrationType `json:"integration_types,omitempty"` + // NOTE: Chat commands only. Otherwise it mustn't be set. Description string `json:"description,omitempty"` From 073114ba6f69f3f658fc8ee91d14d415d3fff915 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Tue, 19 Mar 2024 02:03:11 +0300 Subject: [PATCH 03/17] feat(interactions): implement contexts --- interactions.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/interactions.go b/interactions.go index 5aef4bb4c..c5dd1507d 100644 --- a/interactions.go +++ b/interactions.go @@ -44,6 +44,7 @@ type ApplicationCommand struct { DMPermission *bool `json:"dm_permission,omitempty"` NSFW *bool `json:"nsfw,omitempty"` + Contexts *[]InteractionContextType `json:"contexts,omitempty"` IntegrationTypes *[]ApplicationIntegrationType `json:"integration_types,omitempty"` // NOTE: Chat commands only. Otherwise it mustn't be set. @@ -202,6 +203,14 @@ func (t InteractionType) String() string { return fmt.Sprintf("InteractionType(%d)", t) } +type InteractionContextType uint + +const ( + InteractionContextGuild InteractionContextType = 0 + InteractionContextBotDM InteractionContextType = 1 + InteractionContextPrivateChannel InteractionContextType = 2 +) + // Interaction represents data of an interaction. type Interaction struct { ID string `json:"id"` @@ -235,6 +244,7 @@ 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"` Token string `json:"token"` Version int `json:"version"` } From 132a199a8345a8ab7e1386bb97214e884d34bbf3 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Tue, 19 Mar 2024 02:06:13 +0300 Subject: [PATCH 04/17] feat(Interaction): add authorizing_integration_owners --- interactions.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interactions.go b/interactions.go index c5dd1507d..8243fd8f4 100644 --- a/interactions.go +++ b/interactions.go @@ -245,6 +245,8 @@ type Interaction struct { 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"` } From 6cb4511f80621e02a2d5ad99ddf330433ab59e9d Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Tue, 19 Mar 2024 15:34:23 +0300 Subject: [PATCH 05/17] chore(ApplicationCommand): deprecate DMPermission --- interactions.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interactions.go b/interactions.go index 8243fd8f4..03c335f3c 100644 --- a/interactions.go +++ b/interactions.go @@ -38,12 +38,14 @@ 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"` From 3da7693ba92317f6ee2f027525049cc526302b22 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Tue, 19 Mar 2024 15:34:33 +0300 Subject: [PATCH 06/17] feat(Application): add integration_types_config --- structs.go | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/structs.go b/structs.go index 112436c02..89a4c1874 100644 --- a/structs.go +++ b/structs.go @@ -143,26 +143,36 @@ const ( ApplicationIntegrationUserInstall ApplicationIntegrationType = 1 ) +type ApplicationInstallParams struct { + Scopes []string `json:"scopes"` + Permissions int64 `json:"permissions,string"` +} + +type ApplicationIntegrationTypeConfiguration struct { + OAuth2InstallParams ApplicationInstallParams `json:"oauth2_install_params"` +} + // 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]*ApplicationIntegrationTypeConfiguration `json:"integration_types"` } // ApplicationRoleConnectionMetadataType represents the type of application role connection metadata. From f865de35e9c51e1b6aa394849eb9bd7549826a5f Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 21 Mar 2024 18:13:54 +0300 Subject: [PATCH 07/17] style: apply gofmt --- structs.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/structs.go b/structs.go index 89a4c1874..f55495795 100644 --- a/structs.go +++ b/structs.go @@ -149,29 +149,29 @@ type ApplicationInstallParams struct { } type ApplicationIntegrationTypeConfiguration struct { - OAuth2InstallParams ApplicationInstallParams `json:"oauth2_install_params"` + OAuth2InstallParams ApplicationInstallParams `json:"oauth2_install_params"` } // 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]*ApplicationIntegrationTypeConfiguration `json:"integration_types"` } From 837727b9075e5583f300001d402e6b89cba4fd0a Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 21 Mar 2024 18:23:43 +0300 Subject: [PATCH 08/17] docs: add descriptions to interaction context types --- interactions.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/interactions.go b/interactions.go index 03c335f3c..9ef83ed9c 100644 --- a/interactions.go +++ b/interactions.go @@ -205,11 +205,15 @@ 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 InteractionContextType = 0 - InteractionContextBotDM InteractionContextType = 1 + // 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 ) From b186e8e1388a24b64878b20afb4f7283b636751e Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 21 Mar 2024 20:41:39 +0300 Subject: [PATCH 09/17] docs: add descriptions to application integration types --- structs.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/structs.go b/structs.go index f55495795..fdfecb2ef 100644 --- a/structs.go +++ b/structs.go @@ -136,11 +136,14 @@ 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 ApplicationIntegrationType = 1 + // ApplicationIntegrationUserInstall indicates that app is installable to users. + ApplicationIntegrationUserInstall ApplicationIntegrationType = 1 ) type ApplicationInstallParams struct { From 4195727c4fbf6f1da5c8ee02c185ade657adcd5d Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 21 Mar 2024 20:42:58 +0300 Subject: [PATCH 10/17] docs: add descriptions to integration type config structs --- structs.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/structs.go b/structs.go index fdfecb2ef..bf455b91a 100644 --- a/structs.go +++ b/structs.go @@ -146,11 +146,14 @@ const ( 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"` } +// ApplicationIntegrationTypeConfiguration represents application's configuration for a particular integration type. type ApplicationIntegrationTypeConfiguration struct { OAuth2InstallParams ApplicationInstallParams `json:"oauth2_install_params"` } From 2e2937447b7575579685051d9ec79b528b76139f Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 21 Mar 2024 20:44:42 +0300 Subject: [PATCH 11/17] refactor(ApplicationIntegrationTypeConfiguration): shorten the name --- structs.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/structs.go b/structs.go index bf455b91a..5f8f58c86 100644 --- a/structs.go +++ b/structs.go @@ -153,32 +153,32 @@ type ApplicationInstallParams struct { Permissions int64 `json:"permissions,string"` } -// ApplicationIntegrationTypeConfiguration represents application's configuration for a particular integration type. -type ApplicationIntegrationTypeConfiguration struct { +// ApplicationIntegrationTypeConfig represents application's configuration for a particular integration type. +type ApplicationIntegrationTypeConfig struct { OAuth2InstallParams ApplicationInstallParams `json:"oauth2_install_params"` } // 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"` - IntegrationTypesConfig map[ApplicationIntegrationType]*ApplicationIntegrationTypeConfiguration `json:"integration_types"` + 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"` } // ApplicationRoleConnectionMetadataType represents the type of application role connection metadata. From d2b5cda6d381713362cad6a9433db5a3c40cd08b Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 21 Mar 2024 20:50:40 +0300 Subject: [PATCH 12/17] fix: add a workaround for https://github.com/discord/discord-api-docs/issues/6730 --- interactions.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/interactions.go b/interactions.go index 9ef83ed9c..36db50836 100644 --- a/interactions.go +++ b/interactions.go @@ -261,7 +261,8 @@ type interaction Interaction type rawInteraction struct { interaction - Data json.RawMessage `json:"data"` + Data json.RawMessage `json:"data"` + AuthorizingIntegrationOwners map[ApplicationIntegrationType]json.Number `json:"authorizing_integration_owners"` } // UnmarshalJSON is a method for unmarshalling JSON object to Interaction. @@ -274,6 +275,13 @@ func (i *Interaction) UnmarshalJSON(raw []byte) error { *i = Interaction(tmp.interaction) + // TODO: remove when https://github.com/discord/discord-api-docs/issues/6730 is fixed. + authIntegrationOwners := make(map[ApplicationIntegrationType]string) + for k, v := range tmp.AuthorizingIntegrationOwners { + authIntegrationOwners[k] = v.String() + } + i.AuthorizingIntegrationOwners = authIntegrationOwners + switch tmp.Type { case InteractionApplicationCommand, InteractionApplicationCommandAutocomplete: v := ApplicationCommandInteractionData{} From f18be4cad54d03734309011ee82cb1cb56888943 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 20 Jun 2024 17:19:47 +0300 Subject: [PATCH 13/17] feat(Message): add InteractionMetadata --- message.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/message.go b/message.go index 3b03ed5f9..07bdc21e7 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,14 @@ 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 string `json:"id"` + Type InteractionType `json:"type"` + User *User `json:"user"` + AuthorizingIntegrationOwners map[ApplicationIntegrationType]string `json:"authorizing_integration_owners"` + OriginalResponseMessageID string `json:"original_response_message_id,omitempty"` + InteractedMessageID string `json:"interacted_message_id,omitempty"` + TriggeringInteractionMetadata *MessageInteractionMetadata `json:"triggering_interaction_metadata,omitempty"` +} From b6ba130a9a260681bb84429cfce92ce33f2eff45 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 20 Jun 2024 17:27:54 +0300 Subject: [PATCH 14/17] docs(MessageInteractionMetadata): add documentation to fields --- message.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/message.go b/message.go index 07bdc21e7..5f549dfc8 100644 --- a/message.go +++ b/message.go @@ -573,11 +573,21 @@ type MessageInteraction struct { // MessageInteractionMetadata contains metadata of an interaction, including relevant user info. type MessageInteractionMetadata struct { - ID string `json:"id"` - Type InteractionType `json:"type"` - User *User `json:"user"` - AuthorizingIntegrationOwners map[ApplicationIntegrationType]string `json:"authorizing_integration_owners"` - OriginalResponseMessageID string `json:"original_response_message_id,omitempty"` - InteractedMessageID string `json:"interacted_message_id,omitempty"` - TriggeringInteractionMetadata *MessageInteractionMetadata `json:"triggering_interaction_metadata,omitempty"` + // 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"` } From 75a9085a188765b3b75c97af32503756221d4313 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 20 Jun 2024 17:52:52 +0300 Subject: [PATCH 15/17] feat(ApplicationIntegrationTypeConfig): add omitempty tag to OAuth2InstallParams --- structs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 5f8f58c86..3605bce0c 100644 --- a/structs.go +++ b/structs.go @@ -155,7 +155,7 @@ type ApplicationInstallParams struct { // ApplicationIntegrationTypeConfig represents application's configuration for a particular integration type. type ApplicationIntegrationTypeConfig struct { - OAuth2InstallParams ApplicationInstallParams `json:"oauth2_install_params"` + OAuth2InstallParams *ApplicationInstallParams `json:"oauth2_install_params,omitempty"` } // Application stores values for a Discord Application From 9e879ff84fcec5c54d311a3f3c321e22b74c6463 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 20 Jun 2024 17:53:21 +0300 Subject: [PATCH 16/17] feat(Application): add omitempty tag to IntegrationTypesConfig --- structs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 3605bce0c..0397b9ac2 100644 --- a/structs.go +++ b/structs.go @@ -178,7 +178,7 @@ type Application struct { Slug string `json:"slug"` CoverImage string `json:"cover_image"` Flags int `json:"flags,omitempty"` - IntegrationTypesConfig map[ApplicationIntegrationType]*ApplicationIntegrationTypeConfig `json:"integration_types"` + IntegrationTypesConfig map[ApplicationIntegrationType]*ApplicationIntegrationTypeConfig `json:"integration_types,omitempty"` } // ApplicationRoleConnectionMetadataType represents the type of application role connection metadata. From 879979c396a7708b1c90c675e1fd4fcd6cfb414c Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 20 Jun 2024 17:54:31 +0300 Subject: [PATCH 17/17] chore(Interaction): remove authorizing_integration_owners workaround --- interactions.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/interactions.go b/interactions.go index 36db50836..9ef83ed9c 100644 --- a/interactions.go +++ b/interactions.go @@ -261,8 +261,7 @@ type interaction Interaction type rawInteraction struct { interaction - Data json.RawMessage `json:"data"` - AuthorizingIntegrationOwners map[ApplicationIntegrationType]json.Number `json:"authorizing_integration_owners"` + Data json.RawMessage `json:"data"` } // UnmarshalJSON is a method for unmarshalling JSON object to Interaction. @@ -275,13 +274,6 @@ func (i *Interaction) UnmarshalJSON(raw []byte) error { *i = Interaction(tmp.interaction) - // TODO: remove when https://github.com/discord/discord-api-docs/issues/6730 is fixed. - authIntegrationOwners := make(map[ApplicationIntegrationType]string) - for k, v := range tmp.AuthorizingIntegrationOwners { - authIntegrationOwners[k] = v.String() - } - i.AuthorizingIntegrationOwners = authIntegrationOwners - switch tmp.Type { case InteractionApplicationCommand, InteractionApplicationCommandAutocomplete: v := ApplicationCommandInteractionData{}