From 1593c55523958ab2f7c0473931915efa638718a0 Mon Sep 17 00:00:00 2001 From: Rens Rikkerink <1952177+ikkerens@users.noreply.github.com> Date: Tue, 31 Jul 2018 20:36:58 +0200 Subject: [PATCH] Added .MessageFormat() to emoji struct (#569) * Added .ChatName() to emoji struct * Renamed ChatName to MessageFormat * Fix lint --- structs.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/structs.go b/structs.go index 6acbc3c..d089b5f 100644 --- a/structs.go +++ b/structs.go @@ -281,6 +281,19 @@ type Emoji struct { Animated bool `json:"animated"` } +// MessageFormat returns a correctly formatted Emoji for use in Message content and embeds +func (e *Emoji) MessageFormat() string { + if e.ID != "" && e.Name != "" { + if e.Animated { + return "" + } + + return "<:" + e.APIName() + ">" + } + + return e.APIName() +} + // APIName returns an correctly formatted API name for use in the MessageReactions endpoints. func (e *Emoji) APIName() string { if e.ID != "" && e.Name != "" {