/
emoji.go
49 lines (41 loc) · 1.33 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
package discord
// emoji.go contains all structures for emojis.
// Emoji represents an Emoji on discord.
type Emoji struct {
GuildID *Snowflake `json:"guild_id,omitempty"`
User *User `json:"user,omitempty"`
Name string `json:"name"`
Roles []Snowflake `json:"roles,omitempty"`
ID Snowflake `json:"id"`
RequireColons bool `json:"require_colons"`
Managed bool `json:"managed"`
Animated bool `json:"animated"`
Available bool `json:"available"`
}
// Delete deletes the emoji.
// reason: Reason for deleting the emoji.
func (e *Emoji) Delete(s *Session, reason *string) error {
return DeleteGuildEmoji(s, *e.GuildID, e.ID, reason)
}
// Edit edits the emoji.
// name: The name of the emoji
// roles: Roles this emoji is limited to.
// reason: Reason for editing the emoji.
func (e *Emoji) Edit(s *Session, name string, roles []*Snowflake, reason *string) error {
params := EmojiParams{
Name: name,
Roles: roles,
}
newEmoji, err := ModifyGuildEmoji(s, *e.GuildID, e.ID, params, reason)
if err != nil {
return err
}
*e = *newEmoji
return nil
}
// EmojiParams represents the payload sent to discord.
type EmojiParams struct {
Name string `json:"name"`
Image string `json:"image,omitempty"`
Roles []*Snowflake `json:"roles"`
}