-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
topgg.go
43 lines (34 loc) · 837 Bytes
/
topgg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package utils
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"time"
)
func SendTopggData(token string, botId string, shards uint, dctoken string) {
httpClient := &http.Client{
Timeout: 60 * time.Second,
}
reqBody, err := json.Marshal(map[string]uint{
"server_count": uint(GetConnectedServerCount(dctoken)),
"shard_count": shards,
})
if err != nil {
fmt.Println("Error marshalling top.gg data:", err)
return
}
req, err := http.NewRequest("POST", "https://top.gg/api/bots/"+botId+"/stats", bytes.NewBuffer(reqBody))
req.Header.Set("Content-Type", "application/json")
req.Header.Add("Authorization", token)
if err != nil {
fmt.Println("Error starting request, top.gg data:", err)
return
}
resp, err := httpClient.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
}