瀏覽代碼

Made User-Agent version a variable.

Bruce Marriner 9 年之前
父節點
當前提交
bb60b64ecb
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      restapi.go

+ 4 - 1
restapi.go

@@ -39,12 +39,14 @@ func (s *Session) Request(method, urlStr string, data interface{}) (response []b
 	}
 
 	// Not used on initial login..
+	// TODO: Verify if a login, otherwise complain about no-token
 	if s.Token != "" {
 		req.Header.Set("authorization", s.Token)
 	}
 
 	req.Header.Set("Content-Type", "application/json")
-	req.Header.Set("User-Agent", "DiscordBot (https://github.com/bwmarrin/discordgo, v0.0.0)")
+	// TODO: Make a configurable static variable.
+	req.Header.Set("User-Agent", fmt.Sprintf("DiscordBot (https://github.com/bwmarrin/discordgo, v%s", VERSION))
 	client := &http.Client{Timeout: (20 * time.Second)}
 
 	resp, err := client.Do(req)
@@ -58,6 +60,7 @@ func (s *Session) Request(method, urlStr string, data interface{}) (response []b
 	}
 	resp.Body.Close()
 
+	// TODO check for 401 response, invalidate token if we get one.
 	if resp.StatusCode != 204 && resp.StatusCode != 200 {
 		err = fmt.Errorf("StatusCode: %d, %s", resp.StatusCode, string(response))
 		return