-
Notifications
You must be signed in to change notification settings - Fork 1
/
emoji.go
44 lines (38 loc) · 975 Bytes
/
emoji.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
package objects
import "strings"
var _ Mentionable = (*Emoji)(nil)
type Emoji struct {
ID Snowflake `json:"id"`
Name string `json:"name,omitempty"`
Roles []Snowflake `json:"roles,omitempty"`
User *User `json:"user,omitempty"`
RequireColons bool `json:"require_colons,omitempty"`
Managed bool `json:"managed,omitempty"`
Animated bool `json:"animated,omitempty"`
Available bool `json:"available,omitempty"`
}
func (e *Emoji) Mention() string {
if e.ID != 0 {
var b strings.Builder
b.WriteRune('<')
if e.Animated {
b.WriteRune('a')
}
b.WriteRune(':')
b.WriteString(e.Name)
b.WriteRune(':')
b.WriteString(e.ID.String())
b.WriteRune('>')
return b.String()
} else {
return e.Name
}
}
func (e *Emoji) String() string {
return e.Mention()
}
type Reaction struct {
Count int `json:"count"`
Me bool `json:"me"`
Emoji Emoji `json:"emoji"`
}