1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-05 06:26:08 +00:00
arikawa/api/interaction.go

45 lines
1.2 KiB
Go

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
)
type InteractionResponse struct {
Type InteractionResponseType `json:"type"`
Data *InteractionResponseData `json:"data,omitempty"`
}
// InteractionResponseData is InteractionApplicationCommandCallbackData in the
// official documentation.
type InteractionResponseData struct {
TTS bool `json:"tts"`
Content string `json:"content"`
Embeds []discord.Embed `json:"embeds,omitempty"`
AllowedMentions AllowedMentions `json:"allowed_mentions,omitempty"`
}
// RespondInteraction responds to an incoming interaction. It is also known as
// an "interaction callback".
func (c *Client) RespondInteraction(
id discord.InteractionID, token string, data InteractionResponse) error {
return c.FastRequest(
"POST",
EndpointInteractions+id.String()+"/"+token+"/callback",
httputil.WithJSONBody(data),
)
}