-
Notifications
You must be signed in to change notification settings - Fork 0
/
other.go
324 lines (277 loc) · 8.09 KB
/
other.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
package revolt
import (
"fmt"
"os"
)
// Similar to message, but created for send message function.
type SendMessage struct {
Content string `json:"content"`
Nonce string `json:"nonce,omitempty"`
Attachments []string `json:"attachments,omitempty"`
Replies []Replies `json:"replies,omitempty"`
Embeds []SendableEmbed `json:"embeds,omitempty"`
DeleteAfter uint `json:"-"`
}
type SendableEmbed struct {
Type string `json:"type"`
IconUrl string `json:"icon_url,omitempty"`
Url string `json:"url,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Media string `json:"media,omitempty"`
Colour string `json:"colour,omitempty"`
}
type Replies struct {
Id string `json:"id"`
Mention bool `json:"mention"`
}
// Set content.
func (sms *SendMessage) SetContent(content string) *SendMessage {
sms.Content = content
return sms
}
// Set and format content.
func (sms *SendMessage) SetContentf(format string, values ...interface{}) *SendMessage {
sms.Content = fmt.Sprintf(format, values...)
return sms
}
// Set delete after option.
func (sms *SendMessage) SetDeleteAfter(second uint) *SendMessage {
sms.DeleteAfter = second
return sms
}
// Add a new attachment.
func (sms *SendMessage) AddAttachment(attachment string) *SendMessage {
sms.Attachments = append(sms.Attachments, attachment)
return sms
}
// Add a new reply.
func (sms *SendMessage) AddReply(id string, mention bool) *SendMessage {
sms.Replies = append(sms.Replies, Replies{
Id: id,
Mention: mention,
})
return sms
}
// Create a unique nonce.
func (sms *SendMessage) CreateNonce() *SendMessage {
sms.Nonce = genULID()
return sms
}
// Edit channel struct.
// Please see: https://developers.revolt.chat/api/#tag/Channel-Information/paths/~1channels~1:channel/patch for more information.
type EditChannel struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Remove string `json:"remove,omitempty"`
}
// Set name for struct.
func (ec *EditChannel) SetName(name string) *EditChannel {
ec.Name = name
return ec
}
// Set description for struct.
func (ec *EditChannel) SetDescription(desc string) *EditChannel {
ec.Description = desc
return ec
}
// Set icon for struct.
func (ec *EditChannel) SetIcon(autumn_id string) *EditChannel {
ec.Icon = autumn_id
return ec
}
// Set remove item.
func (ec *EditChannel) RemoveItem(item string) *EditChannel {
ec.Remove = item
return ec
}
// Edit server struct.
// Please see https://developers.revolt.chat/api/#tag/Server-Information/paths/~1servers~1:server/patch for more detail.
type EditServer struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Banner string `json:"banner,omitempty"`
Categories []*Category `json:"categories,omitempty"`
SystemMessages *ServerSystemMessages `json:"system_messages,omitempty"`
Remove string `json:"remove,omitempty"`
}
// Set name for struct
func (es *EditServer) SetName(name string) *EditServer {
es.Name = name
return es
}
// Set description for struct.
func (es *EditServer) SetDescription(desc string) *EditServer {
es.Description = desc
return es
}
// Set icon for struct.
func (es *EditServer) SetIcon(autumn_id string) *EditServer {
es.Icon = autumn_id
return es
}
// Set banner for struct.
func (es *EditServer) SetBanner(autumn_id string) *EditServer {
es.Banner = autumn_id
return es
}
// Add a new category for struct.
func (es *EditServer) AddCategory(category *Category) *EditServer {
es.Categories = append(es.Categories, category)
return es
}
// Set system messages for struct.
func (es *EditServer) SetSystemMessages(sm *ServerSystemMessages) *EditServer {
es.SystemMessages = sm
return es
}
// Set remove item.
func (es *EditServer) RemoveItem(item string) *EditServer {
es.Remove = item
return es
}
// Edit member struct.
// Please see https://developers.revolt.chat/api/#tag/Server-Members/paths/~1servers~1:server~1members~1:member/patch for more information.
type EditMember struct {
Nickname string `json:"nickname,omitempty"`
Avatar string `json:"avatar,omitempty"`
Roles []string `json:"roles,omitempty"`
Remove string `json:"remove,omitempty"`
}
// Set nickname for struct.
func (em *EditMember) SetNickname(nick string) *EditMember {
em.Nickname = nick
return em
}
// Set avatar for struct.
func (em *EditMember) SetAvatar(autumn_id string) *EditMember {
em.Avatar = autumn_id
return em
}
// Add role for struct.
func (em *EditMember) AddRole(role_id string) *EditMember {
em.Roles = append(em.Roles, role_id)
return em
}
// Set remove item.
func (em *EditMember) RemoveItem(item string) *EditMember {
em.Remove = item
return em
}
// Edit role struct.
type EditRole struct {
Name string `json:"name,omitempty"`
Colour string `json:"colour,omitempty"`
Hoist bool `json:"hoist,omitempty"`
Rank int `json:"rank,omitempty"`
Remove string `json:"remove,omitempty"`
}
// Set name for struct.
func (er *EditRole) SetName(name string) *EditRole {
er.Name = name
return er
}
// Set valid HTML color for struct.
func (er *EditRole) SetColour(color string) *EditRole {
er.Colour = color
return er
}
// Set hoist boolean value for struct.
func (er *EditRole) IsHoist(hoist bool) *EditRole {
er.Hoist = hoist
return er
}
// Set role ranking for struct.
func (er *EditRole) SetRank(rank int) *EditRole {
er.Rank = rank
return er
}
// Set role ranking for struct.
func (er *EditRole) RemoveColour() *EditRole {
er.Remove = "Colour"
return er
}
// Edit client user struct.
// See https://developers.revolt.chat/api/#tag/User-Information/paths/~1users~1@me/patch for more information.
type EditUser struct {
Status struct {
Text string `json:"text,omitempty"`
Presence string `json:"presence,omitempty"`
} `json:"status,omitempty"`
Profile struct {
Content string `json:"content,omitempty"`
Background string `json:"background,omitempty"`
} `json:"profile,omitempty"`
Avatar string `json:"avatar,omitempty"`
Remove string `json:"remove,omitempty"`
}
// Set status for struct.
func (eu *EditUser) SetStatus(text, presence string) *EditUser {
eu.Status = struct {
Text string "json:\"text,omitempty\""
Presence string "json:\"presence,omitempty\""
}{
Text: text,
Presence: presence,
}
return eu
}
// Set profile informations for struct.
func (eu *EditUser) SetProfile(content, background string) *EditUser {
eu.Profile = struct {
Content string "json:\"content,omitempty\""
Background string "json:\"background,omitempty\""
}{
Content: content,
Background: background,
}
return eu
}
// Set avatar for struct.
func (eu *EditUser) SetAvatar(autumn_id string) *EditUser {
eu.Avatar = autumn_id
return eu
}
// Set remove item for struct.
func (eu *EditUser) SetRemove(item string) *EditUser {
eu.Remove = item
return eu
}
// revolt binary struct.
type Binary struct {
Data []byte
}
// Save data to the given path.
func (b Binary) Save(path string) error {
return os.WriteFile(path, b.Data, 0666)
}
// Edit bot struct
// Please see https://developers.revolt.chat/api/#tag/Bots/paths/~1bots~1:bot/patch for more information.
type EditBot struct {
Name string `json:"name,omitempty"`
Public bool `json:"public,omitempty"`
InteractionsUrl string `json:"interactionsURL,omitempty"`
Remove string `json:"remove,omitempty"`
}
// Set name for struct.
func (eb *EditBot) SetName(name string) *EditBot {
eb.Name = name
return eb
}
// Set public value for struct.
func (eb *EditBot) SetPublicValue(is_public bool) *EditBot {
eb.Public = is_public
return eb
}
// Set interaction url for struct.
func (eb *EditBot) SetInteractionsUrl(url string) *EditBot {
eb.InteractionsUrl = url
return eb
}
// Remove interaction url for struct.
func (eb *EditBot) RemoveInteractionsUrl() *EditBot {
eb.Remove = "InteractionsURL"
return eb
}