-
Notifications
You must be signed in to change notification settings - Fork 3
/
identify.gleam
33 lines (29 loc) · 857 Bytes
/
identify.gleam
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
import gleam/dynamic
import gleam/map
import gleam/erlang
pub type IdentifyPacketData {
IdentifyPacketData(
token: String,
intents: Int,
shard_id: Int,
total_shards: Int,
)
}
pub fn to_etf(data: IdentifyPacketData) -> BitString {
// TODO make dynamic
let properties =
map.new()
|> map.insert("os", dynamic.from("unix"))
|> map.insert("broswer", dynamic.from("shimmer"))
|> map.insert("device", dynamic.from("shimmer"))
let data =
map.new()
|> map.insert("token", dynamic.from(data.token))
|> map.insert("intents", dynamic.from(data.intents))
|> map.insert("shards", dynamic.from([data.shard_id, data.total_shards]))
|> map.insert("properties", dynamic.from(properties))
map.new()
|> map.insert("op", dynamic.from(2))
|> map.insert("d", dynamic.from(data))
|> erlang.term_to_binary
}