github.com/diamondburned/arikawa/v2@v2.1.0/api/interaction.go (about)

     1  package api
     2  
     3  import (
     4  	"github.com/diamondburned/arikawa/v2/discord"
     5  	"github.com/diamondburned/arikawa/v2/utils/httputil"
     6  )
     7  
     8  var EndpointInteractions = Endpoint + "interactions/"
     9  
    10  type InteractionResponseType uint
    11  
    12  const (
    13  	PongInteraction InteractionResponseType = iota + 1
    14  	AcknowledgeInteraction
    15  	MessageInteraction
    16  	MessageInteractionWithSource
    17  	AcknowledgeInteractionWithSource
    18  )
    19  
    20  type InteractionResponse struct {
    21  	Type InteractionResponseType  `json:"type"`
    22  	Data *InteractionResponseData `json:"data,omitempty"`
    23  }
    24  
    25  // InteractionResponseData is InteractionApplicationCommandCallbackData in the
    26  // official documentation.
    27  type InteractionResponseData struct {
    28  	TTS             bool            `json:"tts"`
    29  	Content         string          `json:"content"`
    30  	Embeds          []discord.Embed `json:"embeds,omitempty"`
    31  	AllowedMentions AllowedMentions `json:"allowed_mentions,omitempty"`
    32  }
    33  
    34  // RespondInteraction responds to an incoming interaction. It is also known as
    35  // an "interaction callback".
    36  func (c *Client) RespondInteraction(
    37  	id discord.InteractionID, token string, data InteractionResponse) error {
    38  
    39  	return c.FastRequest(
    40  		"POST",
    41  		EndpointInteractions+id.String()+"/"+token+"/callback",
    42  		httputil.WithJSONBody(data),
    43  	)
    44  }