From 5452a224bf619dd256d7906e55dad440c49e36e0 Mon Sep 17 00:00:00 2001 From: Eric Wohltman Date: Thu, 19 Dec 2019 12:46:45 -0500 Subject: [PATCH 1/4] Fix for Discord's API returning a 400 Bad Request if Content-Type is set, but the request body is empty. --- restapi.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/restapi.go b/restapi.go index 8134d92..69c5507 100644 --- a/restapi.go +++ b/restapi.go @@ -88,7 +88,12 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b req.Header.Set("authorization", s.Token) } - req.Header.Set("Content-Type", contentType) + // Discord's API returns a 400 Bad Request is Content-Type is set, but the + // request body is empty. + if b != nil { + req.Header.Set("Content-Type", contentType) + } + // TODO: Make a configurable static variable. req.Header.Set("User-Agent", s.UserAgent) From b3cc83b10cce9e09fd126fd9bca044be3f97a4f6 Mon Sep 17 00:00:00 2001 From: Carson Hoffman Date: Fri, 20 Dec 2019 11:46:17 -0500 Subject: [PATCH 2/4] Version 0.20.2: fix for endpoints with empty body --- discord.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord.go b/discord.go index 76f1ad9..ac4e542 100644 --- a/discord.go +++ b/discord.go @@ -21,7 +21,7 @@ import ( ) // VERSION of DiscordGo, follows Semantic Versioning. (http://semver.org/) -const VERSION = "0.20.1" +const VERSION = "0.20.2" // ErrMFA will be risen by New when the user has 2FA. var ErrMFA = errors.New("account has 2FA enabled") From c737258c067a0b91f5c24d273102a896940b9043 Mon Sep 17 00:00:00 2001 From: Helba Date: Wed, 22 Jan 2020 14:50:38 -0800 Subject: [PATCH 3/4] Added missing features --- go.mod | 2 ++ structs.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 2ff8868..8cd2cf6 100644 --- a/go.mod +++ b/go.mod @@ -4,3 +4,5 @@ require ( github.com/gorilla/websocket v1.4.0 golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 ) + +go 1.13 diff --git a/structs.go b/structs.go index fd78fc9..827df72 100644 --- a/structs.go +++ b/structs.go @@ -587,12 +587,13 @@ type VoiceState struct { // A Presence stores the online, offline, or idle and game status of Guild members. type Presence struct { - User *User `json:"user"` - Status Status `json:"status"` - Game *Game `json:"game"` - Nick string `json:"nick"` - Roles []string `json:"roles"` - Since *int `json:"since"` + User *User `json:"user"` + Status Status `json:"status"` + Game *Game `json:"game"` + Activities []*Game `json:"activities"` + Nick string `json:"nick"` + Roles []string `json:"roles"` + Since *int `json:"since"` } // GameType is the type of "game" (see GameType* consts) in the Game struct @@ -604,6 +605,7 @@ const ( GameTypeStreaming GameTypeListening GameTypeWatching + GameTypeCustom ) // A Game struct holds the name of the "playing .." game for a user From 817c9f816a93b9aeeb1ed85f2687f54e0d37c311 Mon Sep 17 00:00:00 2001 From: Helba Date: Thu, 23 Jan 2020 09:50:17 -0800 Subject: [PATCH 4/4] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 8cd2cf6..79ea036 100644 --- a/go.mod +++ b/go.mod @@ -5,4 +5,4 @@ require ( golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 ) -go 1.13 +go 1.10