Skip to content

Instantly share code, notes, and snippets.

@ducc
Created May 13, 2017 10:21
Show Gist options
  • Save ducc/3710f77f1fa38911845f3abfbafbcae7 to your computer and use it in GitHub Desktop.
Save ducc/3710f77f1fa38911845f3abfbafbcae7 to your computer and use it in GitHub Desktop.
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