discord: Add NewAPIEmoji

This commit is contained in:
diamondburned 2022-06-23 00:11:27 -07:00
parent be9de2c165
commit 384a3dd433
No known key found for this signature in database
GPG Key ID: D78C4471CE776659
1 changed files with 11 additions and 1 deletions

View File

@ -94,10 +94,20 @@ func (e Emoji) EmojiURLWithType(t ImageType) string {
// where "123123123" is the emoji ID.
type APIEmoji string
// NewAPIEmoji creates a new APIEmoji string from the given emoji ID and name.
func NewAPIEmoji(id EmojiID, name string) APIEmoji {
if !id.IsValid() {
return APIEmoji(name)
}
return APIEmoji(name + ":" + id.String())
}
// NewCustomEmoji creates a new Emoji using a custom guild emoji as base.
// Unicode emojis should be directly converted.
//
// Deprecated: Use NewAPIEmoji, it does the same exact thing.
func NewCustomEmoji(id EmojiID, name string) APIEmoji {
return APIEmoji(name + ":" + id.String())
return NewAPIEmoji(id, name)
}
// PathString returns the APIEmoji as a path-encoded string.