2021-01-27 17:43:38 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/diamondburned/arikawa/v2/discord"
|
|
|
|
"github.com/diamondburned/arikawa/v2/utils/httputil"
|
|
|
|
)
|
|
|
|
|
|
|
|
var EndpointInteractions = Endpoint + "interactions/"
|
|
|
|
|
|
|
|
type InteractionResponseType uint
|
|
|
|
|
|
|
|
const (
|
|
|
|
PongInteraction InteractionResponseType = iota + 1
|
|
|
|
AcknowledgeInteraction
|
|
|
|
MessageInteraction
|
|
|
|
MessageInteractionWithSource
|
|
|
|
AcknowledgeInteractionWithSource
|
2021-05-12 05:36:03 +00:00
|
|
|
DeferredMessageUpdate
|
|
|
|
UpdateMessage
|
2021-01-27 17:43:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type InteractionResponse struct {
|
|
|
|
Type InteractionResponseType `json:"type"`
|
|
|
|
Data *InteractionResponseData `json:"data,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// InteractionResponseData is InteractionApplicationCommandCallbackData in the
|
|
|
|
// official documentation.
|
|
|
|
type InteractionResponseData struct {
|
2021-05-12 05:36:03 +00:00
|
|
|
TTS bool `json:"tts"`
|
|
|
|
Content string `json:"content"`
|
|
|
|
Components []discord.Component `json:"components,omitempty"`
|
|
|
|
Embeds []discord.Embed `json:"embeds,omitempty"`
|
|
|
|
AllowedMentions AllowedMentions `json:"allowed_mentions,omitempty"`
|
2021-01-27 17:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RespondInteraction responds to an incoming interaction. It is also known as
|
|
|
|
// an "interaction callback".
|
|
|
|
func (c *Client) RespondInteraction(
|
2021-02-18 01:41:19 +00:00
|
|
|
id discord.InteractionID, token string, data InteractionResponse) error {
|
2021-01-27 17:43:38 +00:00
|
|
|
return c.FastRequest(
|
|
|
|
"POST",
|
|
|
|
EndpointInteractions+id.String()+"/"+token+"/callback",
|
|
|
|
httputil.WithJSONBody(data),
|
|
|
|
)
|
|
|
|
}
|