Browse Source

Get webhook message endpoint (#948)

* Get interaction response message by interaction token

* Rename methods
Xpl0itR 3 years ago
parent
commit
e72c457cb4
1 changed files with 24 additions and 0 deletions
  1. 24 0
      restapi.go

+ 24 - 0
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.