From e72c457cb4ae121deeb205e2cad4320d4c732acb Mon Sep 17 00:00:00 2001 From: Xpl0itR Date: Thu, 17 Jun 2021 22:19:10 +0100 Subject: [PATCH] Get webhook message endpoint (#948) * Get interaction response message by interaction token * Rename methods --- restapi.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/restapi.go b/restapi.go index 5291b3a..cf2c330 100644 --- a/restapi.go +++ b/restapi.go @@ -2236,6 +2236,23 @@ func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *Webho return } +// WebhookMessage gets a webhook message. +// webhookID : The ID of a webhook +// token : The auth token for the webhook +// messageID : The ID of message to get +func (s *Session) WebhookMessage(webhookID, token, messageID string) (message *Message, err error) { + uri := EndpointWebhookMessage(webhookID, token, messageID) + + body, err := s.RequestWithBucketID("GET", uri, nil, EndpointWebhookToken("", "")) + if err != nil { + return + } + + err = json.Unmarshal(body, &message) + + return +} + // WebhookMessageEdit edits a webhook message. // webhookID : The ID of a webhook // token : The auth token for the webhook @@ -2557,6 +2574,13 @@ func (s *Session) InteractionRespond(interaction *Interaction, resp *Interaction return err } +// 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") +} + // InteractionResponseEdit edits the response to an interaction. // appID : The application ID. // interaction : Interaction instance.