From 2b359776da6141a496746cfc98fc8573d58c5d75 Mon Sep 17 00:00:00 2001 From: Dan Brakeley Date: Thu, 14 Apr 2022 15:30:21 -0400 Subject: [PATCH] fix error shadowing in InteractionRespond (#1030) --- restapi.go | 7 ++++--- state.go | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/restapi.go b/restapi.go index 090de2713..dff21988c 100644 --- a/restapi.go +++ b/restapi.go @@ -2806,7 +2806,7 @@ func (s *Session) ApplicationCommandPermissionsBatchEdit(appID, guildID string, // InteractionRespond creates the response to an interaction. // interaction : Interaction instance. // resp : Response message data. -func (s *Session) InteractionRespond(interaction *Interaction, resp *InteractionResponse) (err error) { +func (s *Session) InteractionRespond(interaction *Interaction, resp *InteractionResponse) error { endpoint := EndpointInteractionResponse(interaction.ID, interaction.Token) if resp.Data != nil && len(resp.Data.Files) > 0 { @@ -2816,9 +2816,10 @@ func (s *Session) InteractionRespond(interaction *Interaction, resp *Interaction } _, err = s.request("POST", endpoint, contentType, body, endpoint, 0) - } else { - _, err = s.RequestWithBucketID("POST", endpoint, *resp, endpoint) + return err } + + _, err := s.RequestWithBucketID("POST", endpoint, *resp, endpoint) return err } diff --git a/state.go b/state.go index e75be8950..a25d55f50 100644 --- a/state.go +++ b/state.go @@ -979,8 +979,9 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) { err = s.GuildRemove(t.Guild) case *GuildMemberAdd: + var guild *Guild // Updates the MemberCount of the guild. - guild, err := s.Guild(t.Member.GuildID) + guild, err = s.Guild(t.Member.GuildID) if err != nil { return err } @@ -995,8 +996,9 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) { err = s.MemberAdd(t.Member) } case *GuildMemberRemove: + var guild *Guild // Updates the MemberCount of the guild. - guild, err := s.Guild(t.Member.GuildID) + guild, err = s.Guild(t.Member.GuildID) if err != nil { return err }