-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathembed.n
43 lines (34 loc) · 1006 Bytes
/
embed.n
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
import json
let color = imp "./color.n"
// TODO: Add in other types of embeds
class pub Embed (title:maybe[str], description:maybe[str], url:maybe[str], color:maybe[color.Color]) {
let col = imp "./color.n"
let pub getTitle = () -> maybe[str] {
return title
}
let pub getDescription = () -> maybe[str] {
return description
}
let pub getUrl = () -> maybe[str] {
return url
}
let pub getColor = () -> maybe[col.Color] {
return color
}
let pub asJson = () -> json.value {
let mut embedData:list[(str, json.value)] = [("type", json.string("rich"))]
if let yes(t) = title {
embedData = embedData.append(("title", json.string(t)))
}
if let yes(d) = description {
embedData = embedData.append(("description", json.string(d)))
}
if let yes(u) = url {
embedData = embedData.append(("url", json.string(u)))
}
if let yes(c) = color {
embedData = embedData.append(("color", json.number(c.asInt().toFloat())))
}
return json.object(mapFrom(embedData))
}
}