Skip to content

Commit

Permalink
Implement support for Application emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
Big-Iron-Cheems committed Sep 10, 2024
1 parent 41a66e5 commit 2ac4f1e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ var (
EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID }
EndpointApplicationRoleConnectionMetadata = func(aID string) string { return EndpointApplication(aID) + "/role-connections/metadata" }

EndpointApplicationEmojis = func(aID string) string { return EndpointApplication(aID) + "/emojis" }
EndpointApplicationEmoji = func(aID, eID string) string { return EndpointApplication(aID) + "/emojis/" + eID }

EndpointOAuth2 = EndpointAPI + "oauth2/"
EndpointOAuth2Applications = EndpointOAuth2 + "applications"
EndpointOAuth2Application = func(aID string) string { return EndpointOAuth2Applications + "/" + aID }
Expand Down
61 changes: 61 additions & 0 deletions restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,67 @@ func (s *Session) GuildEmojiDelete(guildID, emojiID string, options ...RequestOp
return
}

// ApplicationEmojis returns all emojis for the given application
// appID : ID of the application
func (s *Session) ApplicationEmojis(appID string, options ...RequestOption) (emoji []*Emoji, err error) {
body, err := s.RequestWithBucketID("GET", EndpointApplicationEmojis(appID), nil, EndpointApplicationEmojis(appID), options...)
if err != nil {
return
}

err = unmarshal(body, &emoji)
return
}

// ApplicationEmoji returns the emoji for the given application.
// appID : ID of the application
// emojiID : ID of an Emoji to retrieve
func (s *Session) ApplicationEmoji(appID, emojiID string, options ...RequestOption) (emoji *Emoji, err error) {
var body []byte
body, err = s.RequestWithBucketID("GET", EndpointApplicationEmoji(appID, emojiID), nil, EndpointApplicationEmoji(appID, emojiID), options...)
if err != nil {
return
}

err = unmarshal(body, &emoji)
return
}

// ApplicationEmojiCreate creates a new Emoji for the given application.
// appID : ID of the application
// data : New Emoji data
func (s *Session) ApplicationEmojiCreate(appID string, data *EmojiParams, options ...RequestOption) (emoji *Emoji, err error) {
body, err := s.RequestWithBucketID("POST", EndpointApplicationEmojis(appID), data, EndpointApplicationEmojis(appID), options...)
if err != nil {
return
}

err = unmarshal(body, &emoji)
return
}

// ApplicationEmojiEdit modifies and returns updated Emoji for the given application.
// appID : ID of the application
// emojiID : ID of an Emoji
// data : Updated Emoji data
func (s *Session) ApplicationEmojiEdit(appID string, emojiID string, data *EmojiParams, options ...RequestOption) (emoji *Emoji, err error) {
body, err := s.RequestWithBucketID("PATCH", EndpointApplicationEmoji(appID, emojiID), data, EndpointApplicationEmojis(appID), options...)
if err != nil {
return
}

err = unmarshal(body, &emoji)
return
}

// ApplicationEmojiDelete deletes an Emoji for the given application.
// appID : ID of the application
// emojiID : ID of an Emoji
func (s *Session) ApplicationEmojiDelete(appID, emojiID string, options ...RequestOption) (err error) {
_, err = s.RequestWithBucketID("DELETE", EndpointApplicationEmoji(appID, emojiID), nil, EndpointApplicationEmojis(appID), options...)
return
}

// GuildTemplate returns a GuildTemplate for the given code
// templateCode: The Code of a GuildTemplate
func (s *Session) GuildTemplate(templateCode string, options ...RequestOption) (st *GuildTemplate, err error) {
Expand Down

0 comments on commit 2ac4f1e

Please sign in to comment.