alpha
Login
or
Join now
folospior.dev
/
grom
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
A Discord API Library for Gleam! 💫
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
add some fields to invites
author
Filip Hoffmann
date
5 months ago
(Feb 17, 2026, 10:34 PM +0100)
commit
90c58df3
90c58df34e8ef26e8a2aa2aaa1345cd166ccadbd
parent
45c7c8d8
45c7c8d802c089c8de3d42d34574dc47079a88f5
+75
1 changed file
Expand all
Collapse all
Unified
Split
src
grom
invite.gleam
+75
src/grom/invite.gleam
View file
Reviewed
···
3
3
import gleam/dynamic/decode
4
4
import gleam/http
5
5
import gleam/http/request
6
6
+
import gleam/int
6
7
import gleam/json.{type Json}
7
8
import gleam/list
8
9
import gleam/option.{type Option, None, Some}
···
14
15
import grom/application.{type Application}
15
16
import grom/channel.{type Channel}
16
17
import grom/guild.{type Guild}
18
18
+
import grom/guild/role
19
19
+
import grom/internal/flags
17
20
import grom/internal/rest
18
21
import grom/internal/time_duration
19
22
import grom/internal/time_rfc3339
···
40
43
approximate_presence_count: Option(Int),
41
44
approximate_member_count: Option(Int),
42
45
expires_at: Option(Timestamp),
46
46
+
flags: Option(List(Flag)),
47
47
+
roles: Option(List(PartialRole)),
43
48
)
44
49
}
45
50
51
51
+
pub type PartialRole {
52
52
+
PartialRole(
53
53
+
id: String,
54
54
+
name: String,
55
55
+
position: Int,
56
56
+
colors: role.Colors,
57
57
+
icon_hash: Option(String),
58
58
+
unicode_emoji: Option(String),
59
59
+
)
60
60
+
}
61
61
+
62
62
+
fn partial_role_decoder() -> decode.Decoder(PartialRole) {
63
63
+
use id <- decode.field("id", decode.string)
64
64
+
use name <- decode.field("name", decode.string)
65
65
+
use position <- decode.field("position", decode.int)
66
66
+
use colors <- decode.field("colors", role.colors_decoder())
67
67
+
use icon_hash <- decode.optional_field(
68
68
+
"icon",
69
69
+
None,
70
70
+
decode.optional(decode.string),
71
71
+
)
72
72
+
use unicode_emoji <- decode.optional_field(
73
73
+
"unicode_emoji",
74
74
+
None,
75
75
+
decode.optional(decode.string),
76
76
+
)
77
77
+
decode.success(PartialRole(
78
78
+
id:,
79
79
+
name:,
80
80
+
position:,
81
81
+
colors:,
82
82
+
icon_hash:,
83
83
+
unicode_emoji:,
84
84
+
))
85
85
+
}
86
86
+
46
87
pub type WithMetadata {
47
88
WithMetadata(
48
89
type_: Type,
···
59
100
max_age: Duration,
60
101
is_temporary: Bool,
61
102
created_at: Timestamp,
103
103
+
flags: Option(List(Flag)),
104
104
+
roles: Option(List(PartialRole)),
62
105
)
106
106
+
}
107
107
+
108
108
+
pub type Flag {
109
109
+
IsGuestInvite
110
110
+
}
111
111
+
112
112
+
fn bits_flags() -> List(#(Int, Flag)) {
113
113
+
[#(int.bitwise_shift_left(1, 0), IsGuestInvite)]
63
114
}
64
115
65
116
pub type Create {
···
183
234
None,
184
235
decode.optional(time_rfc3339.decoder()),
185
236
)
237
237
+
use flags <- decode.optional_field(
238
238
+
"flags",
239
239
+
None,
240
240
+
decode.optional(flags.decoder(bits_flags())),
241
241
+
)
242
242
+
use roles <- decode.optional_field(
243
243
+
"roles",
244
244
+
None,
245
245
+
decode.optional(decode.list(of: partial_role_decoder())),
246
246
+
)
186
247
decode.success(WithoutMetadata(
187
248
type_:,
188
249
code:,
···
193
254
approximate_presence_count:,
194
255
approximate_member_count:,
195
256
expires_at:,
257
257
+
flags:,
258
258
+
roles:,
196
259
))
197
260
}
198
261
···
281
344
)
282
345
use is_temporary <- decode.field("temporary", decode.bool)
283
346
use created_at <- decode.field("created_at", time_rfc3339.decoder())
347
347
+
use flags <- decode.optional_field(
348
348
+
"flags",
349
349
+
None,
350
350
+
decode.optional(flags.decoder(bits_flags())),
351
351
+
)
352
352
+
use roles <- decode.optional_field(
353
353
+
"roles",
354
354
+
None,
355
355
+
decode.optional(decode.list(of: partial_role_decoder())),
356
356
+
)
284
357
285
358
decode.success(WithMetadata(
286
359
type_:,
···
297
370
max_age:,
298
371
is_temporary:,
299
372
created_at:,
373
373
+
flags:,
374
374
+
roles:,
300
375
))
301
376
}
302
377