-
Notifications
You must be signed in to change notification settings - Fork 35
/
emoji.go
62 lines (51 loc) · 1.55 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package discord
import (
"time"
"github.com/disgoorg/snowflake/v2"
)
var _ Mentionable = (*Emoji)(nil)
// Emoji allows you to interact with emojis & emotes
type Emoji struct {
ID snowflake.ID `json:"id,omitempty"`
Name string `json:"name,omitempty"` // may be empty for deleted emojis
Roles []snowflake.ID `json:"roles,omitempty"`
Creator *User `json:"creator,omitempty"`
RequireColons bool `json:"require_colons,omitempty"`
Managed bool `json:"managed,omitempty"`
Animated bool `json:"animated,omitempty"`
Available bool `json:"available,omitempty"`
}
// Mention returns the string used to send the Emoji
func (e Emoji) Mention() string {
if e.Animated {
return AnimatedEmojiMention(e.ID, e.Name)
}
return EmojiMention(e.ID, e.Name)
}
// String formats the Emoji as string
func (e Emoji) String() string {
return e.Mention()
}
func (e Emoji) URL(opts ...CDNOpt) string {
return formatAssetURL(CustomEmoji, opts, e.ID)
}
func (e Emoji) CreatedAt() time.Time {
if e.ID == 0 {
return time.Time{}
}
return e.ID.Time()
}
type EmojiCreate struct {
Name string `json:"name"`
Image Icon `json:"image"`
Roles []snowflake.ID `json:"roles,omitempty"`
}
type EmojiUpdate struct {
Name string `json:"name,omitempty"`
Roles []snowflake.ID `json:"roles,omitempty"`
}
type ReactionEmoji struct {
ID snowflake.ID `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Animated bool `json:"animated"`
}