Skip to content

Commit

Permalink
Fix interaction events (#264)
Browse files Browse the repository at this point in the history
* fix events.XInteractionCreate not implementing discord.Interaction anymore

* mark Interaction.ChannelID as depreacted

* cleanup interaction events
  • Loading branch information
topi314 committed Apr 10, 2023
1 parent a50f1ef commit 4929351
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions discord/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Interaction interface {
Token() string
Version() int
GuildID() *snowflake.ID
// Deprecated: Use Interaction.Channel instead
ChannelID() snowflake.ID
Channel() *PartialChannel
Locale() Locale
Expand Down
30 changes: 15 additions & 15 deletions events/interaction_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func (e *InteractionCreate) Guild() (discord.Guild, bool) {
return discord.Guild{}, false
}

// Channel returns the discord.GuildMessageChannel that the interaction happened in.
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
// This only returns cached channels.
func (e *InteractionCreate) Channel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.ChannelID())
func (e *InteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
}

// ApplicationCommandInteractionCreate is the base struct for all application command interaction create events.
Expand All @@ -48,10 +48,10 @@ func (e *ApplicationCommandInteractionCreate) Guild() (discord.Guild, bool) {
return discord.Guild{}, false
}

// Channel returns the discord.GuildMessageChannel that the interaction happened in.
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
// This only returns cached channels.
func (e *ApplicationCommandInteractionCreate) Channel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.ApplicationCommandInteraction.Channel().ID)
func (e *ApplicationCommandInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
}

// CreateMessage responds to the interaction with a new message.
Expand Down Expand Up @@ -90,10 +90,10 @@ func (e *ComponentInteractionCreate) Guild() (discord.Guild, bool) {
return discord.Guild{}, false
}

// Channel returns the discord.GuildMessageChannel that the interaction happened in.
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
// This only returns cached channels.
func (e *ComponentInteractionCreate) Channel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.ComponentInteraction.Channel().ID)
func (e *ComponentInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
}

// CreateMessage responds to the interaction with a new message.
Expand Down Expand Up @@ -142,10 +142,10 @@ func (e *AutocompleteInteractionCreate) Guild() (discord.Guild, bool) {
return discord.Guild{}, false
}

// Channel returns the discord.GuildMessageChannel that the interaction happened in.
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
// This only returns cached channels.
func (e *AutocompleteInteractionCreate) Channel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.AutocompleteInteraction.Channel().ID)
func (e *AutocompleteInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
}

// Result responds to the interaction with a slice of choices.
Expand All @@ -170,10 +170,10 @@ func (e *ModalSubmitInteractionCreate) Guild() (discord.Guild, bool) {
return discord.Guild{}, false
}

// Channel returns the discord.GuildMessageChannel that the interaction happened in.
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
// This only returns cached channels.
func (e *ModalSubmitInteractionCreate) Channel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.ModalSubmitInteraction.Channel().ID)
func (e *ModalSubmitInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
}

// CreateMessage responds to the interaction with a new message.
Expand Down

0 comments on commit 4929351

Please sign in to comment.