bwmarrin / discordgo

(Golang) Go bindings for Discord
BSD 3-Clause "New" or "Revised" License
5.05k stars 802 forks source link

REST API: support Application emojis #1567

Open Big-Iron-Cheems opened 3 weeks ago

Big-Iron-Cheems commented 3 weeks ago

As of now, discordgo's restapi.go supports control of Guild based emojis, but not Application based ones. The docs related to Guild and Application emojis are located here: https://discord.com/developers/docs/resources/emoji. I am interested in supporting all the endpoints that begin with /applications/.

Screenshot below is from the https://discord.com/developers/applications/APPLICATION_ID/emojis page. image

Currently I have written this function in my personal project to GET a specific emoji by ID:

// applicationEmoji fetches an emoji from the application
func applicationEmoji(s *discordgo.Session, applicationID string, emojiID string, options ...discordgo.RequestOption) (emoji *discordgo.Emoji, err error) {
    var body []byte
    body, err = s.RequestWithBucketID("GET", discordgo.EndpointApplication(applicationID)+"/emojis/"+emojiID, nil, discordgo.EndpointApplication(applicationID), options...)
    if err != nil {
        return
    }

    err = discordgo.Unmarshal(body, &emoji)
    return
}

// Example usage in my project
emoji, err = applicationEmoji(s, applicationID, emojiID)

I am working on an implementation that is close to the Guild emoji functions. Progress tracked at this PR, suggestions appreciated.