diff --git a/examples/components/main.go b/examples/components/main.go index d3c20f7f9..45b580333 100644 --- a/examples/components/main.go +++ b/examples/components/main.go @@ -139,7 +139,7 @@ var ( panic(err) } time.Sleep(time.Second) // Doing that so user won't see instant response. - _, err = s.FollowupMessageCreate(*AppID, i.Interaction, true, &discordgo.WebhookParams{ + _, err = s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "Anyways, now when you know how to use single select menus, let's see how multi select menus work. " + "Try calling `/selects multi` command.", Flags: 1 << 6, @@ -164,7 +164,7 @@ var ( panic(err) } time.Sleep(time.Second) // Doing that so user won't see instant response. - _, err = s.FollowupMessageCreate(*AppID, i.Interaction, true, &discordgo.WebhookParams{ + _, err = s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "Now you know everything about select component. If you want to know more or ask a question - feel free to.", Components: []discordgo.MessageComponent{ discordgo.ActionsRow{ diff --git a/examples/context_menus/main.go b/examples/context_menus/main.go index 1d82a22d0..f5d4b92ef 100644 --- a/examples/context_menus/main.go +++ b/examples/context_menus/main.go @@ -85,7 +85,7 @@ var ( i.ApplicationCommandData().TargetID, ) if err != nil { - _, err = s.FollowupMessageCreate(*AppID, i.Interaction, true, &discordgo.WebhookParams{ + _, err = s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: fmt.Sprintf("Mission failed. Cannot send a message to this user: %q", err.Error()), Flags: 1 << 6, }) diff --git a/examples/slash_commands/main.go b/examples/slash_commands/main.go index 704150c86..b464a4795 100644 --- a/examples/slash_commands/main.go +++ b/examples/slash_commands/main.go @@ -369,7 +369,7 @@ var ( Type: discordgo.InteractionResponseType(i.ApplicationCommandData().Options[0].IntValue()), }) if err != nil { - s.FollowupMessageCreate(s.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{ + s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "Something went wrong", }) } @@ -383,25 +383,25 @@ var ( }, }) if err != nil { - s.FollowupMessageCreate(s.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{ + s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "Something went wrong", }) return } time.AfterFunc(time.Second*5, func() { - _, err = s.InteractionResponseEdit(s.State.User.ID, i.Interaction, &discordgo.WebhookEdit{ + _, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{ Content: content + "\n\nWell, now you know how to create and edit responses. " + "But you still don't know how to delete them... so... wait 10 seconds and this " + "message will be deleted.", }) if err != nil { - s.FollowupMessageCreate(s.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{ + s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "Something went wrong", }) return } time.Sleep(time.Second * 10) - s.InteractionResponseDelete(s.State.User.ID, i.Interaction) + s.InteractionResponseDelete(i.Interaction) }) }, "followups": func(s *discordgo.Session, i *discordgo.InteractionCreate) { @@ -419,26 +419,26 @@ var ( Content: "Surprise!", }, }) - msg, err := s.FollowupMessageCreate(s.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{ + msg, err := s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "Followup message has been created, after 5 seconds it will be edited", }) if err != nil { - s.FollowupMessageCreate(s.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{ + s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "Something went wrong", }) return } time.Sleep(time.Second * 5) - s.FollowupMessageEdit(s.State.User.ID, i.Interaction, msg.ID, &discordgo.WebhookEdit{ + s.FollowupMessageEdit(i.Interaction, msg.ID, &discordgo.WebhookEdit{ Content: "Now the original message is gone and after 10 seconds this message will ~~self-destruct~~ be deleted.", }) time.Sleep(time.Second * 10) - s.FollowupMessageDelete(s.State.User.ID, i.Interaction, msg.ID) + s.FollowupMessageDelete(i.Interaction, msg.ID) - s.FollowupMessageCreate(s.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{ + s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: "For those, who didn't skip anything and followed tutorial along fairly, " + "take a unicorn :unicorn: as reward!\n" + "Also, as bonus... look at the original interaction response :D", diff --git a/interactions.go b/interactions.go index 0551e476b..7164f65ee 100644 --- a/interactions.go +++ b/interactions.go @@ -180,6 +180,7 @@ func (t InteractionType) String() string { // Interaction represents data of an interaction. type Interaction struct { ID string `json:"id"` + AppID string `json:"application_id"` Type InteractionType `json:"type"` Data InteractionData `json:"data"` GuildID string `json:"guild_id"` diff --git a/restapi.go b/restapi.go index fcefcbbdd..090de2713 100644 --- a/restapi.go +++ b/restapi.go @@ -2823,25 +2823,22 @@ func (s *Session) InteractionRespond(interaction *Interaction, resp *Interaction } // InteractionResponse gets the response to an interaction. -// appID : The application ID. // interaction : Interaction instance. -func (s *Session) InteractionResponse(appID string, interaction *Interaction) (*Message, error) { - return s.WebhookMessage(appID, interaction.Token, "@original") +func (s *Session) InteractionResponse(interaction *Interaction) (*Message, error) { + return s.WebhookMessage(interaction.AppID, interaction.Token, "@original") } // InteractionResponseEdit edits the response to an interaction. -// appID : The application ID. // interaction : Interaction instance. // newresp : Updated response message data. -func (s *Session) InteractionResponseEdit(appID string, interaction *Interaction, newresp *WebhookEdit) (*Message, error) { - return s.WebhookMessageEdit(appID, interaction.Token, "@original", newresp) +func (s *Session) InteractionResponseEdit(interaction *Interaction, newresp *WebhookEdit) (*Message, error) { + return s.WebhookMessageEdit(interaction.AppID, interaction.Token, "@original", newresp) } // InteractionResponseDelete deletes the response to an interaction. -// appID : The application ID. // interaction : Interaction instance. -func (s *Session) InteractionResponseDelete(appID string, interaction *Interaction) error { - endpoint := EndpointInteractionResponseActions(appID, interaction.Token) +func (s *Session) InteractionResponseDelete(interaction *Interaction) error { + endpoint := EndpointInteractionResponseActions(interaction.AppID, interaction.Token) _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint) @@ -2849,29 +2846,26 @@ func (s *Session) InteractionResponseDelete(appID string, interaction *Interacti } // FollowupMessageCreate creates the followup message for an interaction. -// appID : The application ID. // interaction : Interaction instance. // wait : Waits for server confirmation of message send and ensures that the return struct is populated (it is nil otherwise) // data : Data of the message to send. -func (s *Session) FollowupMessageCreate(appID string, interaction *Interaction, wait bool, data *WebhookParams) (*Message, error) { - return s.WebhookExecute(appID, interaction.Token, wait, data) +func (s *Session) FollowupMessageCreate(interaction *Interaction, wait bool, data *WebhookParams) (*Message, error) { + return s.WebhookExecute(interaction.AppID, interaction.Token, wait, data) } // FollowupMessageEdit edits a followup message of an interaction. -// appID : The application ID. // interaction : Interaction instance. // messageID : The followup message ID. // data : Data to update the message -func (s *Session) FollowupMessageEdit(appID string, interaction *Interaction, messageID string, data *WebhookEdit) (*Message, error) { - return s.WebhookMessageEdit(appID, interaction.Token, messageID, data) +func (s *Session) FollowupMessageEdit(interaction *Interaction, messageID string, data *WebhookEdit) (*Message, error) { + return s.WebhookMessageEdit(interaction.AppID, interaction.Token, messageID, data) } // FollowupMessageDelete deletes a followup message of an interaction. -// appID : The application ID. // interaction : Interaction instance. // messageID : The followup message ID. -func (s *Session) FollowupMessageDelete(appID string, interaction *Interaction, messageID string) error { - return s.WebhookMessageDelete(appID, interaction.Token, messageID) +func (s *Session) FollowupMessageDelete(interaction *Interaction, messageID string) error { + return s.WebhookMessageDelete(interaction.AppID, interaction.Token, messageID) } // ------------------------------------------------------------------------------------------------