forked from pothtonswer/discordmuffin
Merge pull request #551 from Seklfreak/add-emoji-methods
adds GuildEmojiCreate, GuildEmojiEdit, and GuildEmojiDelete
This commit is contained in:
commit
adc6a99c3d
2 changed files with 54 additions and 0 deletions
|
@ -95,6 +95,8 @@ var (
|
||||||
EndpointGuildSplash = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
|
EndpointGuildSplash = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
|
||||||
EndpointGuildWebhooks = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
|
EndpointGuildWebhooks = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
|
||||||
EndpointGuildAuditLogs = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
|
EndpointGuildAuditLogs = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
|
||||||
|
EndpointGuildEmojis = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
|
||||||
|
EndpointGuildEmoji = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
|
||||||
|
|
||||||
EndpointChannel = func(cID string) string { return EndpointChannels + cID }
|
EndpointChannel = func(cID string) string { return EndpointChannels + cID }
|
||||||
EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
|
EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
|
||||||
|
|
52
restapi.go
52
restapi.go
|
@ -1285,6 +1285,58 @@ func (s *Session) GuildAuditLog(guildID, userID, beforeID string, actionType, li
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GuildEmojiCreate creates a new emoji
|
||||||
|
// guildID : The ID of a Guild.
|
||||||
|
// name : The Name of the Emoji.
|
||||||
|
// image : The base64 encoded emoji image, has to be smaller than 256KB.
|
||||||
|
// roles : The roles for which this emoji will be whitelisted, can be nil.
|
||||||
|
func (s *Session) GuildEmojiCreate(guildID, name, image string, roles []string) (emoji *Emoji, err error) {
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Image string `json:"image"`
|
||||||
|
Roles []string `json:"roles,omitempty"`
|
||||||
|
}{name, image, roles}
|
||||||
|
|
||||||
|
body, err := s.RequestWithBucketID("POST", EndpointGuildEmojis(guildID), data, EndpointGuildEmojis(guildID))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = unmarshal(body, &emoji)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GuildEmojiEdit modifies an emoji
|
||||||
|
// guildID : The ID of a Guild.
|
||||||
|
// emojiID : The ID of an Emoji.
|
||||||
|
// name : The Name of the Emoji.
|
||||||
|
// roles : The roles for which this emoji will be whitelisted, can be nil.
|
||||||
|
func (s *Session) GuildEmojiEdit(guildID, emojiID, name string, roles []string) (emoji *Emoji, err error) {
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Roles []string `json:"roles,omitempty"`
|
||||||
|
}{name, roles}
|
||||||
|
|
||||||
|
body, err := s.RequestWithBucketID("PATCH", EndpointGuildEmoji(guildID, emojiID), data, EndpointGuildEmojis(guildID))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = unmarshal(body, &emoji)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GuildEmojiDelete deletes an Emoji.
|
||||||
|
// guildID : The ID of a Guild.
|
||||||
|
// emojiID : The ID of an Emoji.
|
||||||
|
func (s *Session) GuildEmojiDelete(guildID, emojiID string) (err error) {
|
||||||
|
|
||||||
|
_, err = s.RequestWithBucketID("DELETE", EndpointGuildEmoji(guildID, emojiID), nil, EndpointGuildEmojis(guildID))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Functions specific to Discord Channels
|
// Functions specific to Discord Channels
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue