From a6d2557a8e837e794f3664d3a4036d4bf3a01b3c Mon Sep 17 00:00:00 2001 From: diamond's alt <51140562+datutbrus@users.noreply.github.com> Date: Sun, 21 Jul 2019 21:06:20 -0700 Subject: [PATCH] Added Asset and ApplicationAssets (#666) Fixed ApplicationAssets returning the wrong type Added Asset and ApplicationAssets --- endpoints.go | 9 +++++---- oauth2.go | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/endpoints.go b/endpoints.go index a5c59ed..d3fe034 100644 --- a/endpoints.go +++ b/endpoints.go @@ -141,8 +141,9 @@ var ( EndpointEmoji = func(eID string) string { return EndpointAPI + "emojis/" + eID + ".png" } EndpointEmojiAnimated = func(eID string) string { return EndpointAPI + "emojis/" + eID + ".gif" } - EndpointOauth2 = EndpointAPI + "oauth2/" - EndpointApplications = EndpointOauth2 + "applications" - EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID } - EndpointApplicationsBot = func(aID string) string { return EndpointApplications + "/" + aID + "/bot" } + EndpointOauth2 = EndpointAPI + "oauth2/" + EndpointApplications = EndpointOauth2 + "applications" + EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID } + EndpointApplicationsBot = func(aID string) string { return EndpointApplications + "/" + aID + "/bot" } + EndpointApplicationAssets = func(aID string) string { return EndpointApplications + "/" + aID + "/assets" } ) diff --git a/oauth2.go b/oauth2.go index 108b32f..4a52120 100644 --- a/oauth2.go +++ b/oauth2.go @@ -105,6 +105,25 @@ func (s *Session) ApplicationDelete(appID string) (err error) { return } +// Asset struct stores values for an asset of an application +type Asset struct { + Type int `json:"type"` + ID string `json:"id"` + Name string `json:"name"` +} + +// ApplicationAssets returns an application's assets +func (s *Session) ApplicationAssets(appID string) (ass []*Asset, err error) { + + body, err := s.RequestWithBucketID("GET", EndpointApplicationAssets(appID), nil, EndpointApplicationAssets("")) + if err != nil { + return + } + + err = unmarshal(body, &ass) + return +} + // ------------------------------------------------------------------------------------------------ // Code specific to Discord OAuth2 Application Bots // ------------------------------------------------------------------------------------------------