@@ -13,7 +13,11 @@
// Package discordgo provides Discord binding for Go
package discordgo
-import "fmt"
+import (
+ "fmt"
+ "net/http"
+ "time"
+)
// VERSION of Discordgo, follows Symantic Versioning. (http://semver.org/)
const VERSION = "0.16.0-dev"
@@ -43,6 +47,7 @@ func New(args ...interface{}) (s *Session, err error) {
ShardID: 0,
ShardCount: 1,
MaxRestRetries: 3,
+ Client: &http.Client{Timeout: (20 * time.Second)},
}
// If no arguments are passed return the empty Session interface.
@@ -87,9 +87,7 @@ func (s *Session) request(method, urlStr, contentType string, b []byte, bucketID
- client := &http.Client{Timeout: (20 * time.Second)}
-
- resp, err := client.Do(req)
+ resp, err := s.Client.Do(req)
if err != nil {
bucket.Release(nil)
return
@@ -13,6 +13,7 @@ package discordgo
import (
"encoding/json"
"strconv"
"sync"
"time"
@@ -73,6 +74,9 @@ type Session struct {
// StateEnabled is true.
State *State
+ // The http client used for REST requests
+ Client *http.Client
+
// Event handlers
handlersMu sync.RWMutex
handlers map[string][]*eventHandlerInstance