-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstructures.go
More file actions
151 lines (126 loc) · 4.76 KB
/
structures.go
File metadata and controls
151 lines (126 loc) · 4.76 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package webhooks
import (
"encoding/json"
"io"
)
type Webhook struct {
ID string `json:"id"`
Type int `json:"type"`
GuildID *string `json:"guild_id"`
ChannelID string `json:"channel_id"`
Name string `json:"name"`
Avatar string `json:"avatar"`
ApplicationID *string `json:"application_id"`
}
type ModifyWebhook struct {
Name string `json:"name,omitempty"`
Avatar string `json:"avatar,omitempty"`
ChannelID string `json:"channel_id,omitempty"`
}
type WebhookFile struct {
FileName string
Reader io.Reader
}
type EmbedFooter struct {
Text string `json:"text,omitempty"`
IconURL string `json:"icon_url,omitempty"`
ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}
type EmbedImage struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Height int `json:"height,omitempty"`
Width int `json:"width,omitempty"`
}
type EmbedThumbnail EmbedImage
type EmbedAuthor struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
IconURL string `json:"icon_url,omitempty"`
ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}
type EmbedField struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Inline bool `json:"inline,omitempty"`
}
type Embed struct {
Title string `json:"title,omitempty"`
// Type string `json:"type,omitempty"` -- Always rich for Webhooks, field not necessary.
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Color int `json:"color,omitempty"`
Footer *EmbedFooter `json:"footer,omitempty"`
Image *EmbedImage `json:"image,omitempty"`
Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"`
Author *EmbedAuthor `json:"author,omitempty"`
Fields []EmbedField `json:"fields,omitempty"`
}
type AllowedMentionsParse string
var (
AllowedMentionsParseUsers AllowedMentionsParse = "users"
AllowedMentionsParseRoles AllowedMentionsParse = "roles"
AllowedMentionsParseEveryone AllowedMentionsParse = "everyone"
)
type AllowedMentions struct {
Parse []AllowedMentionsParse `json:"parse,omitempty"`
Roles []string `json:"roles,omitempty"`
Users []string `json:"users,omitempty"`
RepliedUser bool `json:"replied_user,omitempty"`
}
// Supported message flags for Webhooks.
type MessageFlag int
var (
MessaegFlagSuppressEmbeds MessageFlag = 1 << 2
MessageFlagSuppressNotifications MessageFlag = 1 << 12
MessageFlagIsComponentsV2 MessageFlag = 1 << 15
)
type PollQuestion struct {
Text string `json:"text,omitempty"`
// Emoji interface{} `json:"emoji,omitempty"` -- Webhooks only support the "Text" field in this structure.
}
type PollMedia struct {
Text string `json:"text,omitempty"`
// Emoji interface{} `json:"emoji,omitempty"` -- Webhooks only support the "Text" field in this structure.
}
type PollAnswer struct {
AnswerID string `json:"answer_id,omitempty"`
}
type Poll struct {
Question *PollQuestion `json:"question,omitempty"`
Answers []PollAnswer `json:"answers,omitempty"`
Expiry string `json:"expiry,omitempty"`
AllowMultiselect bool `json:"allow_multiselect,omitempty"`
}
type MessagePayload struct {
Content string `json:"content,omitempty"`
Username string `json:"username,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
TTS bool `json:"tts,omitempty"`
Embeds []Embed `json:"embeds,omitempty"`
AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
Flags *MessageFlag `json:"flags,omitempty"`
ThreadName string `json:"thread_name,omitempty"`
AppliedTags []string `json:"applied_tags,omitempty"`
Components []Component `json:"components,omitempty"`
Files []WebhookFile `json:"-"`
}
// PayloadJSON will return JSON encoded of non-file params
func (p *MessagePayload) PayloadJSON() string {
json, _ := json.Marshal(p)
return string(json)
}
type EditMessagePayload struct {
Content string `json:"content,omitempty"`
Embeds []Embed `json:"embeds,omitempty"`
Flags *MessageFlag `json:"flags,omitempty"`
AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
Components []Component `json:"components,omitempty"`
Files []WebhookFile `json:"-"`
}
// PayloadJSON will return JSON encoded of non-file params
func (p *EditMessagePayload) PayloadJSON() string {
json, _ := json.Marshal(p)
return string(json)
}