-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.v
316 lines (281 loc) · 7.74 KB
/
structs.v
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
module vord
import time
import x.json2 as json
import snowflake
pub struct Ready {
pub mut:
v int
session_id string
shard []int
application Application
user User
guilds []UnavailableGuild
}
pub struct Raw {
pub mut:
op byte
d string
s u32
t string
}
pub struct Message {
pub mut:
id string
channel_id string
content string
guild_id string
author User
embeds []MessageEmbed
timestamp time.Time
edited_timestamp time.Time
pinned bool
message_type int
webhook_id string
tts bool
mention_everyone bool
nonce int
flags int
}
pub struct Channel {
pub mut:
id string
@type ChannelType
guild_id string
position int
name string
topic string
nsfw bool
last_message_id string
bitrate int
user_limit int
rate_limit_per_user int
recipients []User
icon string
owner_id string
parent_id string
last_pin_timestamp time.Time
rtc_region string
video_quality_mode int
message_count int
default_auto_archive_duration int
permissions string
}
pub enum ChannelType {
guild_text
dm
guild_voice
group_dm
guild_category
guild_news
guild_store
guild_news_thread = 10
guild_public_thread = 11
guild_private_thread = 12
guild_stage_voice = 13
}
pub fn (message Message) snowflake() snowflake.Snowflake {
return snowflake.deconstruct(message.id.u64())
}
pub struct MessageEmbed {
pub mut:
title string
description string
url string
provider MessageEmbedProvider
footer MessageEmbedFooter
fields []MessageEmbedField
author MessageEmbedAuthor
embed_type string
timestamp time.Time
color int
image MessageEmbedImage
thumbnail MessageEmbedThumbnail
video MessageEmbedVideo
}
pub fn (embed MessageEmbed) to_json() json.Any {
mut data := map[string]json.Any{}
data['title'] = embed.title
data['description'] = embed.description
data['color'] = embed.color
data['footer'] = embed.footer.to_json()
data['image'] = embed.image.to_json()
data['thumbnail'] = embed.thumbnail.to_json()
data['author'] = embed.author.to_json()
data['fields'] = embed.fields.to_json()
return data
}
pub fn (embeds []MessageEmbed) to_json() json.Any {
mut data := []json.Any{}
for embed in embeds {
data << embed.to_json()
}
return data
}
pub struct MessageEmbedProvider {
pub mut:
name string
url string
}
pub struct MessageEmbedImage {
pub mut:
url string
proxy_url string
height int
width int
}
pub fn (image MessageEmbedImage) to_json() json.Any {
mut data := map[string]json.Any{}
data['url'] = image.url
data['proxy_url'] = image.proxy_url
data['height'] = image.height
data['width'] = image.width
return data
}
pub struct MessageEmbedThumbnail {
pub mut:
url string
proxy_url string
height int
width int
}
pub fn (thumbnail MessageEmbedThumbnail) to_json() json.Any {
mut data := map[string]json.Any{}
data['url'] = thumbnail.url
data['proxy_url'] = thumbnail.proxy_url
data['height'] = thumbnail.height
data['width'] = thumbnail.width
return data
}
pub struct MessageEmbedVideo {
pub mut:
url string
proxy_url string
height int
width int
}
pub struct MessageEmbedAuthor {
pub mut:
name string
url string
icon_url string
proxy_icon_url string
}
pub fn (author MessageEmbedAuthor) to_json() json.Any {
mut data := map[string]json.Any{}
data['name'] = author.name
data['url'] = author.url
data['icon_url'] = author.icon_url
data['proxy_icon_url'] = author.proxy_icon_url
return data
}
pub struct MessageEmbedFooter {
pub mut:
text string
icon_url string
proxy_icon_url string
}
pub fn (footer MessageEmbedFooter) to_json() json.Any {
mut data := map[string]json.Any{}
data['text'] = footer.text
data['icon_url'] = footer.icon_url
data['proxy_icon_url'] = footer.proxy_icon_url
return data
}
pub struct MessageEmbedField {
pub mut:
name string
value string
inline bool
}
pub fn (field MessageEmbedField) to_json() json.Any {
mut data := map[string]json.Any{}
data['name'] = field.name
data['value'] = field.value
data['inline'] = field.inline
return data
}
pub fn (fields []MessageEmbedField) to_json() json.Any {
mut data := []json.Any{}
for field in fields {
data << field.to_json()
}
return data
}
pub struct UnavailableGuild {
pub mut:
id string
unavailable bool
}
pub struct Application {
pub mut:
id string
name string
owner User
icon string
description string
rpc_origins []string
bot_public bool
bot_require_code_grant bool
terms_of_service_url string
privacy_policy_url string
summary string
verify_key string
team Team
guild_id string
primary_sku_id string
slug string
cover_image string
flags int
}
pub struct User {
pub mut:
id string
username string
discriminator string
avatar string
client bool
system bool
mfa_enabled bool
banner string
accent_color int
locale string
verified bool
email string
flags int
premium_type int
public_flags int
premium_since int
}
pub struct Team {
pub mut:
icon string
id string
members []TeamMember
name string
owner_user_id string
}
pub struct TeamMember {
pub mut:
user User
permissions []string
team_id string
membership_state int
}
pub struct MessagePayload {
pub mut:
content string
embeds []MessageEmbed = voidptr(0)
tts bool
}
pub struct CreateChannelData {
pub mut:
name string
topic string
bitrate int = 8000
user_limit int
rate_limit_per_user int
position int
parent_id string
nsfw bool
}
pub type ChannelEditData = CreateChannelData