Skip to content

Commit

Permalink
Add InteractionGuild (#276)
Browse files Browse the repository at this point in the history
* add InteractionGuild

* bruh
  • Loading branch information
Sebastian authored May 16, 2024
1 parent 9356c13 commit 71cd768
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
20 changes: 14 additions & 6 deletions discord/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
Expand Down Expand Up @@ -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"`
}
2 changes: 2 additions & 0 deletions discord/interaction_application_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions discord/interaction_autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions discord/interaction_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type baseInteraction struct {
applicationID snowflake.ID
token string
version int
guild *InteractionGuild
guildID *snowflake.ID
channelID snowflake.ID
channel InteractionChannel
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions discord/interaction_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions discord/interaction_modal_submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions discord/interaction_ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71cd768

Please sign in to comment.