Created
May 13, 2017 10:21
-
-
Save ducc/3710f77f1fa38911845f3abfbafbcae7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"fmt | |
"net/http" | |
"bytes" | |
) | |
type statsForm struct { | |
ServerCount int `json:"server_count"` | |
} | |
var ( | |
stats statsForm | |
clientId string | |
authToken string | |
) | |
func stats() { | |
body, err := json.Marshal(&stats) | |
if err != nil { | |
fmt.Println("Oh no! An error!", err); | |
return; | |
} | |
client := &http.Client{} | |
req, err := http.NewRequest("POST", "https://bots.discord.pw/api/bots/" + clientId + "/stats", bytes.NewBuffer(body)) | |
if err != nil { | |
fmt.Println("Oh no! An error!", err); | |
return; | |
} | |
req.Header.set("Content-Type", "application/json") | |
req.Header.Set("Authorization", authToken) | |
_, err = client.Do(req) | |
if err != nil { | |
fmt.Println("Oh no! An error!", err); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment