Skip to content

Commit

Permalink
Add Reaction() to emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed Apr 17, 2023
1 parent 4929351 commit 85a5848
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions discord/emoji.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package discord

import (
"fmt"
"time"

"github.com/disgoorg/snowflake/v2"
Expand All @@ -21,6 +22,10 @@ type Emoji struct {
Available bool `json:"available,omitempty"`
}

func (e Emoji) Reaction() string {
return reaction(&e.ID, e.Name)
}

// Mention returns the string used to send the Emoji
func (e Emoji) Mention() string {
if e.Animated {
Expand Down Expand Up @@ -61,3 +66,14 @@ type PartialEmoji struct {
Name *string `json:"name"`
Animated bool `json:"animated"`
}

func (e PartialEmoji) Reaction() string {
return reaction(e.ID, *e.Name)
}

func reaction(id *snowflake.ID, name string) string {
if id == nil {
return name
}
return fmt.Sprintf("%s:%s", id, name)
}

0 comments on commit 85a5848

Please sign in to comment.