Skip to content

Commit e9d502c

Browse files
authored
Add ComponentEmoji constructors and builder methods (#459)
1 parent 0720f59 commit e9d502c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

discord/component.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,26 @@ type ComponentEmoji struct {
242242
Animated bool `json:"animated,omitempty"`
243243
}
244244

245+
// NewComponentEmoji creates a new ComponentEmoji with the provided name (for Unicode emojis)
246+
func NewComponentEmoji(name string) ComponentEmoji {
247+
return ComponentEmoji{
248+
Name: name,
249+
}
250+
}
251+
252+
// NewCustomComponentEmoji creates a new ComponentEmoji with the provided id (for custom Discord emojis)
253+
func NewCustomComponentEmoji(id snowflake.ID) ComponentEmoji {
254+
return ComponentEmoji{
255+
ID: id,
256+
}
257+
}
258+
259+
// WithAnimated returns a new ComponentEmoji with the provided animated flag
260+
func (c ComponentEmoji) WithAnimated(animated bool) ComponentEmoji {
261+
c.Animated = animated
262+
return c
263+
}
264+
245265
func NewActionRow(components ...InteractiveComponent) ActionRowComponent {
246266
return ActionRowComponent{
247267
Components: components,

0 commit comments

Comments
 (0)