added useragent (#653)

This commit is contained in:
diamond's alt 2019-05-28 16:52:23 -07:00 committed by Chris Rhodes
parent 2748413597
commit 7896167153
3 changed files with 5 additions and 1 deletions

View file

@ -58,6 +58,7 @@ func New(args ...interface{}) (s *Session, err error) {
ShardCount: 1,
MaxRestRetries: 3,
Client: &http.Client{Timeout: (20 * time.Second)},
UserAgent: "DiscordBot (https://github.com/bwmarrin/discordgo, v" + VERSION + ")",
sequence: new(int64),
LastHeartbeatAck: time.Now().UTC(),
}

View file

@ -90,7 +90,7 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
req.Header.Set("Content-Type", contentType)
// TODO: Make a configurable static variable.
req.Header.Set("User-Agent", "DiscordBot (https://github.com/bwmarrin/discordgo, v"+VERSION+")")
req.Header.Set("User-Agent", s.UserAgent)
if s.Debug {
for k, v := range req.Header {

View file

@ -82,6 +82,9 @@ type Session struct {
// The http client used for REST requests
Client *http.Client
// The user agent used for REST APIs
UserAgent string
// Stores the last HeartbeatAck that was recieved (in UTC)
LastHeartbeatAck time.Time