From 384a3dd4336bd3f139b6c45d0fe3807280797787 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Thu, 23 Jun 2022 00:11:27 -0700 Subject: [PATCH] discord: Add NewAPIEmoji --- discord/emoji.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/discord/emoji.go b/discord/emoji.go index 295c65d..d4856aa 100644 --- a/discord/emoji.go +++ b/discord/emoji.go @@ -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.