forked from pothtonswer/discordmuffin
Application Emojis (#1566)
--------- Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
parent
0a25bf41b9
commit
247b6f7a76
3 changed files with 74 additions and 0 deletions
|
@ -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 }
|
||||
|
|
70
restapi.go
70
restapi.go
|
@ -1454,6 +1454,76 @@ 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) (emojis []*Emoji, err error) {
|
||||
body, err := s.RequestWithBucketID("GET", EndpointApplicationEmojis(appID), nil, EndpointApplicationEmojis(appID), options...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var temp struct {
|
||||
Items []*Emoji `json:"items"`
|
||||
}
|
||||
|
||||
err = unmarshal(body, &temp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
emojis = temp.Items
|
||||
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) {
|
||||
|
|
|
@ -647,6 +647,7 @@ type EmojiParams struct {
|
|||
// NOTE: can be only set on creation.
|
||||
Image string `json:"image,omitempty"`
|
||||
// Roles for which this emoji will be available.
|
||||
// NOTE: can not be used with application emoji endpoints.
|
||||
Roles []string `json:"roles,omitempty"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue