-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactions.go
40 lines (37 loc) · 975 Bytes
/
interactions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package diskursus
import (
"encoding/json"
"io"
"net/http"
"strings"
)
type InteractionRequest struct {
Type int `json:"type"`
ApplicationID string `json:"application_id"`
MessageFlags *int `json:"message_flags,omitempty"`
MessageID *string `json:"message_id,omitempty"`
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
SessionID string `json:"session_id"`
Data map[string]any `json:"data"`
}
func (c *DiscordClient) SendInteraction(request *InteractionRequest) (error) {
reqBody, err := json.Marshal(request)
if err != nil {
return err
}
req, err := http.NewRequest("POST", DiscordApi + "/interactions", strings.NewReader(string(reqBody)))
if err != nil {
return err
}
resp, err := c.do(req)
if err != nil {
return err
}
defer resp.Body.Close()
_, err = io.ReadAll(resp.Body)
if err != nil {
return err
}
return nil
}