2020-01-02 19:53:08 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
type Emoji struct {
|
2020-01-04 04:19:24 +00:00
|
|
|
ID Snowflake `json:"id,string"` // 0 for Unicode emojis
|
2020-01-02 19:53:08 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
|
|
// These fields are optional
|
|
|
|
|
|
|
|
RoleIDs []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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// APIString returns a string usable for sending over to the API.
|
|
|
|
func (e Emoji) APIString() string {
|
|
|
|
if e.ID == 0 {
|
|
|
|
return e.Name // is unicode
|
|
|
|
}
|
|
|
|
|
2020-01-25 08:05:14 +00:00
|
|
|
return e.Name + ":" + e.ID.String()
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// String formats the string like how the client does.
|
|
|
|
func (e Emoji) String() string {
|
|
|
|
if e.ID == 0 {
|
|
|
|
return e.Name
|
|
|
|
}
|
|
|
|
|
2020-01-25 08:05:14 +00:00
|
|
|
var parts = [3]string{
|
2020-01-02 19:53:08 +00:00
|
|
|
"", e.Name, e.ID.String(),
|
|
|
|
}
|
|
|
|
|
|
|
|
if e.Animated {
|
|
|
|
parts[0] = "a"
|
|
|
|
}
|
|
|
|
|
2020-01-25 08:05:14 +00:00
|
|
|
return "<" + strings.Join(parts[:], ":") + ">"
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|