diff --git a/discord/interaction.go b/discord/interaction.go index 139c3f5f..59f131da 100644 --- a/discord/interaction.go +++ b/discord/interaction.go @@ -29,12 +29,13 @@ const ( ) type rawInteraction struct { - ID snowflake.ID `json:"id"` - Type InteractionType `json:"type"` - ApplicationID snowflake.ID `json:"application_id"` - Token string `json:"token"` - Version int `json:"version"` - GuildID *snowflake.ID `json:"guild_id,omitempty"` + ID snowflake.ID `json:"id"` + Type InteractionType `json:"type"` + ApplicationID snowflake.ID `json:"application_id"` + Token string `json:"token"` + Version int `json:"version"` + Guild *InteractionGuild `json:"guild,omitempty"` + GuildID *snowflake.ID `json:"guild_id,omitempty"` // Deprecated: Use Channel instead ChannelID snowflake.ID `json:"channel_id,omitempty"` Channel InteractionChannel `json:"channel,omitempty"` @@ -55,6 +56,7 @@ type Interaction interface { ApplicationID() snowflake.ID Token() string Version() int + Guild() *InteractionGuild GuildID() *snowflake.ID // Deprecated: Use Interaction.Channel instead ChannelID() snowflake.ID @@ -203,3 +205,9 @@ func (c InteractionChannel) MarshalJSON() ([]byte, error) { return json.Merge(mData, pData) } + +type InteractionGuild struct { + ID snowflake.ID `json:"id"` + Locale Locale `json:"locale"` + Features []GuildFeature `json:"features"` +} diff --git a/discord/interaction_application_command.go b/discord/interaction_application_command.go index 0681097c..d3c0292a 100644 --- a/discord/interaction_application_command.go +++ b/discord/interaction_application_command.go @@ -70,6 +70,7 @@ func (i *ApplicationCommandInteraction) UnmarshalJSON(data []byte) error { i.baseInteraction.applicationID = interaction.ApplicationID i.baseInteraction.token = interaction.Token i.baseInteraction.version = interaction.Version + i.baseInteraction.guild = interaction.Guild i.baseInteraction.guildID = interaction.GuildID i.baseInteraction.channelID = interaction.ChannelID i.baseInteraction.channel = interaction.Channel @@ -97,6 +98,7 @@ func (i ApplicationCommandInteraction) MarshalJSON() ([]byte, error) { ApplicationID: i.applicationID, Token: i.token, Version: i.version, + Guild: i.guild, GuildID: i.guildID, ChannelID: i.channelID, Channel: i.channel, diff --git a/discord/interaction_autocomplete.go b/discord/interaction_autocomplete.go index 7d78a9f3..640fcfb4 100644 --- a/discord/interaction_autocomplete.go +++ b/discord/interaction_autocomplete.go @@ -27,6 +27,7 @@ func (i *AutocompleteInteraction) UnmarshalJSON(data []byte) error { i.baseInteraction.applicationID = interaction.ApplicationID i.baseInteraction.token = interaction.Token i.baseInteraction.version = interaction.Version + i.baseInteraction.guild = interaction.Guild i.baseInteraction.guildID = interaction.GuildID i.baseInteraction.channelID = interaction.ChannelID i.baseInteraction.channel = interaction.Channel @@ -54,6 +55,7 @@ func (i AutocompleteInteraction) MarshalJSON() ([]byte, error) { ApplicationID: i.applicationID, Token: i.token, Version: i.version, + Guild: i.guild, GuildID: i.guildID, ChannelID: i.channelID, Channel: i.channel, diff --git a/discord/interaction_base.go b/discord/interaction_base.go index a4c98b18..f6683472 100644 --- a/discord/interaction_base.go +++ b/discord/interaction_base.go @@ -11,6 +11,7 @@ type baseInteraction struct { applicationID snowflake.ID token string version int + guild *InteractionGuild guildID *snowflake.ID channelID snowflake.ID channel InteractionChannel @@ -36,6 +37,9 @@ func (i baseInteraction) Token() string { func (i baseInteraction) Version() int { return i.version } +func (i baseInteraction) Guild() *InteractionGuild { + return i.guild +} func (i baseInteraction) GuildID() *snowflake.ID { return i.guildID } diff --git a/discord/interaction_component.go b/discord/interaction_component.go index c33916be..8ab31223 100644 --- a/discord/interaction_component.go +++ b/discord/interaction_component.go @@ -80,6 +80,7 @@ func (i *ComponentInteraction) UnmarshalJSON(data []byte) error { i.baseInteraction.applicationID = interaction.ApplicationID i.baseInteraction.token = interaction.Token i.baseInteraction.version = interaction.Version + i.baseInteraction.guild = interaction.Guild i.baseInteraction.guildID = interaction.GuildID i.baseInteraction.channelID = interaction.ChannelID i.baseInteraction.channel = interaction.Channel @@ -110,6 +111,7 @@ func (i ComponentInteraction) MarshalJSON() ([]byte, error) { ApplicationID: i.applicationID, Token: i.token, Version: i.version, + Guild: i.guild, GuildID: i.guildID, ChannelID: i.channelID, Channel: i.channel, diff --git a/discord/interaction_modal_submit.go b/discord/interaction_modal_submit.go index 98c4156e..204fdb45 100644 --- a/discord/interaction_modal_submit.go +++ b/discord/interaction_modal_submit.go @@ -24,6 +24,7 @@ func (i *ModalSubmitInteraction) UnmarshalJSON(data []byte) error { i.baseInteraction.applicationID = interaction.ApplicationID i.baseInteraction.token = interaction.Token i.baseInteraction.version = interaction.Version + i.baseInteraction.guild = interaction.Guild i.baseInteraction.guildID = interaction.GuildID i.baseInteraction.channelID = interaction.ChannelID i.baseInteraction.channel = interaction.Channel @@ -51,6 +52,7 @@ func (i ModalSubmitInteraction) MarshalJSON() ([]byte, error) { ApplicationID: i.applicationID, Token: i.token, Version: i.version, + Guild: i.guild, GuildID: i.guildID, ChannelID: i.channelID, Channel: i.channel, diff --git a/discord/interaction_ping.go b/discord/interaction_ping.go index 268d369f..8b586890 100644 --- a/discord/interaction_ping.go +++ b/discord/interaction_ping.go @@ -63,6 +63,9 @@ func (i PingInteraction) Version() int { func (i PingInteraction) CreatedAt() time.Time { return i.id.Time() } +func (PingInteraction) Guild() *InteractionGuild { + return nil +} func (PingInteraction) GuildID() *snowflake.ID { return nil