diff --git a/discord.go b/discord.go index 77d1341..cb43e7e 100644 --- a/discord.go +++ b/discord.go @@ -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(), } diff --git a/restapi.go b/restapi.go index 84a2a31..ce1e823 100644 --- a/restapi.go +++ b/restapi.go @@ -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 { diff --git a/structs.go b/structs.go index c643bd5..01a6f00 100644 --- a/structs.go +++ b/structs.go @@ -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