From e7278b7178a7be169275eef9e133df59008d20f9 Mon Sep 17 00:00:00 2001 From: TopiSenpai Date: Mon, 10 Jan 2022 20:49:59 +0100 Subject: [PATCH] fix Ambiguous Reference in interactions --- core/application_command_interaction.go | 6 +++++- core/autocomplete_interaction.go | 6 +++++- core/component_interaction.go | 6 +++++- core/entity_builder.go | 8 +++++++- core/interaction.go | 7 ++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/core/application_command_interaction.go b/core/application_command_interaction.go index ecf1e48b..af4778f6 100644 --- a/core/application_command_interaction.go +++ b/core/application_command_interaction.go @@ -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) } diff --git a/core/autocomplete_interaction.go b/core/autocomplete_interaction.go index 31340e7f..2ec94b5e 100644 --- a/core/autocomplete_interaction.go +++ b/core/autocomplete_interaction.go @@ -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...) } diff --git a/core/component_interaction.go b/core/component_interaction.go index 4fb1b643..b0c4fa49 100644 --- a/core/component_interaction.go +++ b/core/component_interaction.go @@ -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) } diff --git a/core/entity_builder.go b/core/entity_builder.go index 850246ff..1981231e 100644 --- a/core/entity_builder.go +++ b/core/entity_builder.go @@ -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, } } diff --git a/core/interaction.go b/core/interaction.go index 39670bc7..d0606185 100644 --- a/core/interaction.go +++ b/core/interaction.go @@ -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