forked from pothtonswer/discordmuffin
Made User-Agent version a variable.
This commit is contained in:
parent
40a7e717f5
commit
bb60b64ecb
1 changed files with 4 additions and 1 deletions
|
@ -39,12 +39,14 @@ func (s *Session) Request(method, urlStr string, data interface{}) (response []b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not used on initial login..
|
// Not used on initial login..
|
||||||
|
// TODO: Verify if a login, otherwise complain about no-token
|
||||||
if s.Token != "" {
|
if s.Token != "" {
|
||||||
req.Header.Set("authorization", s.Token)
|
req.Header.Set("authorization", s.Token)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
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)}
|
client := &http.Client{Timeout: (20 * time.Second)}
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
@ -58,6 +60,7 @@ func (s *Session) Request(method, urlStr string, data interface{}) (response []b
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
|
||||||
|
// TODO check for 401 response, invalidate token if we get one.
|
||||||
if resp.StatusCode != 204 && resp.StatusCode != 200 {
|
if resp.StatusCode != 204 && resp.StatusCode != 200 {
|
||||||
err = fmt.Errorf("StatusCode: %d, %s", resp.StatusCode, string(response))
|
err = fmt.Errorf("StatusCode: %d, %s", resp.StatusCode, string(response))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue