Skip to content

Commit

Permalink
fix Ambiguous Reference in interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jan 10, 2022
1 parent 07549dd commit e7278b7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
6 changes: 5 additions & 1 deletion core/application_command_interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ type ApplicationCommandInteractionFilter func(interaction *ApplicationCommandInt

// ApplicationCommandInteraction represents a generic ApplicationCommandInteraction received from discord
type ApplicationCommandInteraction struct {
discord.ApplicationCommandInteraction
*ReplyInteraction
Data ApplicationCommandInteractionData
}

func (i ApplicationCommandInteraction) interaction() {}
func (i ApplicationCommandInteraction) Type() discord.InteractionType {
return discord.InteractionTypeApplicationCommand
}

func (i ApplicationCommandInteraction) SlashCommandInteractionData() *SlashCommandInteractionData {
return i.Data.(*SlashCommandInteractionData)
}
Expand Down
6 changes: 5 additions & 1 deletion core/autocomplete_interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import (
type AutocompleteInteractionFilter func(autocompleteInteraction *AutocompleteInteraction) bool

type AutocompleteInteraction struct {
discord.AutocompleteInteraction
*BaseInteraction
Data AutocompleteInteractionData
}

func (i AutocompleteInteraction) interaction() {}
func (i AutocompleteInteraction) Type() discord.InteractionType {
return discord.InteractionTypeAutocomplete
}

func (i AutocompleteInteraction) Result(choices []discord.AutocompleteChoice, opts ...rest.RequestOpt) error {
return i.Respond(discord.InteractionCallbackTypeAutocompleteResult, discord.AutocompleteResult{Choices: choices}, opts...)
}
Expand Down
6 changes: 5 additions & 1 deletion core/component_interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ type ComponentInteractionFilter func(interaction *ComponentInteraction) bool

// ComponentInteraction represents a generic ComponentInteraction received from discord
type ComponentInteraction struct {
discord.ComponentInteraction
*ReplyInteraction
Data ComponentInteractionData
Message *Message
}

func (i ComponentInteraction) interaction() {}
func (i ComponentInteraction) Type() discord.InteractionType {
return discord.InteractionTypeComponent
}

func (i ComponentInteraction) ButtonInteractionData() *ButtonInteractionData {
return i.Data.(*ButtonInteractionData)
}
Expand Down
8 changes: 7 additions & 1 deletion core/entity_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,16 @@ func (b *entityBuilderImpl) Bot() *Bot {
func (b *entityBuilderImpl) baseInteraction(baseInteraction discord.BaseInteraction, c chan<- discord.InteractionResponse, updateCache CacheStrategy) *BaseInteraction {
member, user := b.parseMemberOrUser(baseInteraction.GuildID, baseInteraction.Member, baseInteraction.User, updateCache)
return &BaseInteraction{
BaseInteraction: baseInteraction,
ID: baseInteraction.ID,
ApplicationID: baseInteraction.ApplicationID,
Token: baseInteraction.Token,
Version: baseInteraction.Version,
GuildID: baseInteraction.GuildID,
ChannelID: baseInteraction.ChannelID,
Member: member,
User: user,
ResponseChannel: c,
Acknowledged: false,
Bot: b.bot,
}
}
Expand Down
7 changes: 6 additions & 1 deletion core/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ type Interaction interface {
}

type BaseInteraction struct {
discord.BaseInteraction
ID discord.Snowflake
ApplicationID discord.Snowflake
Token string
Version int
GuildID *discord.Snowflake
ChannelID discord.Snowflake
Member *Member
User *User
ResponseChannel chan<- discord.InteractionResponse
Expand Down

0 comments on commit e7278b7

Please sign in to comment.