/
message_create.go
42 lines (37 loc) · 1.51 KB
/
message_create.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
41
42
package discord
import (
"github.com/disgoorg/snowflake/v2"
)
// MessageCreate is the struct to create a new Message with
type MessageCreate struct {
Nonce string `json:"nonce,omitempty"`
Content string `json:"content,omitempty"`
TTS bool `json:"tts,omitempty"`
Embeds []Embed `json:"embeds,omitempty"`
Components []ContainerComponent `json:"components,omitempty"`
StickerIDs []snowflake.ID `json:"sticker_ids,omitempty"`
Files []*File `json:"-"`
Attachments []AttachmentCreate `json:"attachments,omitempty"`
AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
MessageReference *MessageReference `json:"message_reference,omitempty"`
Flags MessageFlags `json:"flags,omitempty"`
EnforceNonce bool `json:"enforce_nonce,omitempty"`
Poll *PollCreate `json:"poll,omitempty"`
}
func (MessageCreate) interactionCallbackData() {}
// ToBody returns the MessageCreate ready for body
func (m MessageCreate) ToBody() (any, error) {
if len(m.Files) > 0 {
m.Attachments = parseAttachments(m.Files)
return PayloadWithFiles(m, m.Files...)
}
return m, nil
}
func (m MessageCreate) ToResponseBody(response InteractionResponse) (any, error) {
if len(m.Files) > 0 {
m.Attachments = parseAttachments(m.Files)
response.Data = m
return PayloadWithFiles(response, m.Files...)
}
return response, nil
}