mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-19 21:32:49 +00:00
10c8837000
* all: Added Components fields to message-related types * discord: Documented Reactions field * discord: Implement fix for Component * gateway: Added User and Message fields to InteractionCreateEvent * api: Made InteractionResponseData fields optional for UpdateMessage responses * api: Deprecated and updated interaction response types * gateway: Update optional interaction event fields * discord: Added ComponentWrap for json unmarshalling * state: Update components on MessageUpdate * Updated buttons example
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package api
|
|
|
|
import (
|
|
"github.com/diamondburned/arikawa/v2/discord"
|
|
"github.com/diamondburned/arikawa/v2/utils/httputil"
|
|
"github.com/diamondburned/arikawa/v2/utils/json/option"
|
|
)
|
|
|
|
var EndpointInteractions = Endpoint + "interactions/"
|
|
|
|
type InteractionResponseType uint
|
|
|
|
// https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactioncallbacktype
|
|
const (
|
|
PongInteraction InteractionResponseType = iota + 1
|
|
_
|
|
_
|
|
MessageInteractionWithSource
|
|
DeferredMessageInteractionWithSource
|
|
DeferredMessageUpdate
|
|
UpdateMessage
|
|
)
|
|
|
|
type InteractionResponse struct {
|
|
Type InteractionResponseType `json:"type"`
|
|
Data *InteractionResponseData `json:"data,omitempty"`
|
|
}
|
|
|
|
// InteractionResponseData is InteractionApplicationCommandCallbackData in the
|
|
// official documentation.
|
|
type InteractionResponseData struct {
|
|
TTS option.NullableBool `json:"tts,omitempty"`
|
|
Content option.NullableString `json:"content,omitempty"`
|
|
Components *[]discord.Component `json:"components,omitempty"`
|
|
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),
|
|
)
|
|
}
|