Skip to content

Commit

Permalink
Add Channel to interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed Apr 6, 2023
1 parent 94621e3 commit 4193750
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 6 deletions.
5 changes: 5 additions & 0 deletions discord/channel.go
Expand Up @@ -1145,6 +1145,11 @@ type FollowChannel struct {
ChannelID snowflake.ID `json:"webhook_channel_id"`
}

type PartialChannel struct {
ID snowflake.ID `json:"id"`
Type ChannelType `json:"type"`
}

// VideoQualityMode https://com/developers/docs/resources/channel#channel-object-video-quality-modes
type VideoQualityMode int

Expand Down
15 changes: 9 additions & 6 deletions discord/interaction.go
Expand Up @@ -21,13 +21,15 @@ 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"`
GuildID *snowflake.ID `json:"guild_id,omitempty"`
// Deprecated: Use Channel instead
ChannelID snowflake.ID `json:"channel_id,omitempty"`
Channel *PartialChannel `json:"channel,omitempty"`
Locale Locale `json:"locale,omitempty"`
GuildLocale *Locale `json:"guild_locale,omitempty"`
Member *ResolvedMember `json:"member,omitempty"`
Expand All @@ -44,6 +46,7 @@ type Interaction interface {
Version() int
GuildID() *snowflake.ID
ChannelID() snowflake.ID
Channel() *PartialChannel
Locale() Locale
GuildLocale() *Locale
Member() *ResolvedMember
Expand Down
2 changes: 2 additions & 0 deletions discord/interaction_application_command.go
Expand Up @@ -72,6 +72,7 @@ func (i *ApplicationCommandInteraction) UnmarshalJSON(data []byte) error {
i.baseInteraction.version = interaction.Version
i.baseInteraction.guildID = interaction.GuildID
i.baseInteraction.channelID = interaction.ChannelID
i.baseInteraction.channel = interaction.Channel
i.baseInteraction.locale = interaction.Locale
i.baseInteraction.guildLocale = interaction.GuildLocale
i.baseInteraction.member = interaction.Member
Expand All @@ -95,6 +96,7 @@ func (i ApplicationCommandInteraction) MarshalJSON() ([]byte, error) {
Version: i.version,
GuildID: i.guildID,
ChannelID: i.channelID,
Channel: i.channel,
Locale: i.locale,
GuildLocale: i.guildLocale,
Member: i.member,
Expand Down
2 changes: 2 additions & 0 deletions discord/interaction_autocomplete.go
Expand Up @@ -29,6 +29,7 @@ func (i *AutocompleteInteraction) UnmarshalJSON(data []byte) error {
i.baseInteraction.version = interaction.Version
i.baseInteraction.guildID = interaction.GuildID
i.baseInteraction.channelID = interaction.ChannelID
i.baseInteraction.channel = interaction.Channel
i.baseInteraction.locale = interaction.Locale
i.baseInteraction.guildLocale = interaction.GuildLocale
i.baseInteraction.member = interaction.Member
Expand All @@ -52,6 +53,7 @@ func (i AutocompleteInteraction) MarshalJSON() ([]byte, error) {
Version: i.version,
GuildID: i.guildID,
ChannelID: i.channelID,
Channel: i.channel,
Locale: i.locale,
GuildLocale: i.guildLocale,
Member: i.member,
Expand Down
6 changes: 6 additions & 0 deletions discord/interaction_base.go
Expand Up @@ -13,6 +13,7 @@ type baseInteraction struct {
version int
guildID *snowflake.ID
channelID snowflake.ID
channel *PartialChannel
locale Locale
guildLocale *Locale
member *ResolvedMember
Expand All @@ -35,9 +36,14 @@ func (i baseInteraction) Version() int {
func (i baseInteraction) GuildID() *snowflake.ID {
return i.guildID
}

// Deprecated: Use Channel() instead
func (i baseInteraction) ChannelID() snowflake.ID {
return i.channelID
}
func (i baseInteraction) Channel() *PartialChannel {
return i.channel
}
func (i baseInteraction) Locale() Locale {
return i.locale
}
Expand Down
2 changes: 2 additions & 0 deletions discord/interaction_component.go
Expand Up @@ -82,6 +82,7 @@ func (i *ComponentInteraction) UnmarshalJSON(data []byte) error {
i.baseInteraction.version = interaction.Version
i.baseInteraction.guildID = interaction.GuildID
i.baseInteraction.channelID = interaction.ChannelID
i.baseInteraction.channel = interaction.Channel
i.baseInteraction.locale = interaction.Locale
i.baseInteraction.guildLocale = interaction.GuildLocale
i.baseInteraction.member = interaction.Member
Expand All @@ -108,6 +109,7 @@ func (i ComponentInteraction) MarshalJSON() ([]byte, error) {
Version: i.version,
GuildID: i.guildID,
ChannelID: i.channelID,
Channel: i.channel,
Locale: i.locale,
GuildLocale: i.guildLocale,
Member: i.member,
Expand Down
2 changes: 2 additions & 0 deletions discord/interaction_modal_submit.go
Expand Up @@ -26,6 +26,7 @@ func (i *ModalSubmitInteraction) UnmarshalJSON(data []byte) error {
i.baseInteraction.version = interaction.Version
i.baseInteraction.guildID = interaction.GuildID
i.baseInteraction.channelID = interaction.ChannelID
i.baseInteraction.channel = interaction.Channel
i.baseInteraction.locale = interaction.Locale
i.baseInteraction.guildLocale = interaction.GuildLocale
i.baseInteraction.member = interaction.Member
Expand All @@ -49,6 +50,7 @@ func (i ModalSubmitInteraction) MarshalJSON() ([]byte, error) {
Version: i.version,
GuildID: i.guildID,
ChannelID: i.channelID,
Channel: i.channel,
Locale: i.locale,
GuildLocale: i.guildLocale,
Member: i.member,
Expand Down
4 changes: 4 additions & 0 deletions discord/interaction_ping.go
Expand Up @@ -72,6 +72,10 @@ func (PingInteraction) ChannelID() snowflake.ID {
return 0
}

func (PingInteraction) Channel() *PartialChannel {
return nil
}

func (PingInteraction) Locale() Locale {
return ""
}
Expand Down

0 comments on commit 4193750

Please sign in to comment.