Skip to content

Commit

Permalink
added useragent (bwmarrin#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
datutbrus authored and iopred committed May 28, 2019
1 parent c3db203 commit 7b8648d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down
2 changes: 1 addition & 1 deletion restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7b8648d

Please sign in to comment.