Added Asset and ApplicationAssets (#666)

Fixed ApplicationAssets returning the wrong type

Added Asset and ApplicationAssets
This commit is contained in:
diamond's alt 2019-07-21 21:06:20 -07:00 committed by Chris Rhodes
parent e405cbd54c
commit a6d2557a8e
2 changed files with 24 additions and 4 deletions

View file

@ -145,4 +145,5 @@ var (
EndpointApplications = EndpointOauth2 + "applications" EndpointApplications = EndpointOauth2 + "applications"
EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID } EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID }
EndpointApplicationsBot = func(aID string) string { return EndpointApplications + "/" + aID + "/bot" } EndpointApplicationsBot = func(aID string) string { return EndpointApplications + "/" + aID + "/bot" }
EndpointApplicationAssets = func(aID string) string { return EndpointApplications + "/" + aID + "/assets" }
) )

View file

@ -105,6 +105,25 @@ func (s *Session) ApplicationDelete(appID string) (err error) {
return 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 // Code specific to Discord OAuth2 Application Bots
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------