Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealToxicDev committed Jun 13, 2022
1 parent 67bf8c1 commit d61cf78
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,11 @@ print(req.json())
getBotsFn := rateLimitWrap(10, 1*time.Minute, "gbot", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")

if r.Method == "POST" {
statsFn(w, r)
return
}

if r.Method != "GET" {
w.WriteHeader(http.StatusMethodNotAllowed)
w.Write([]byte(methodNotAllowed))
Expand Down Expand Up @@ -1394,6 +1399,7 @@ print(req.json())
}))

r.HandleFunc("/bots/{id}", getBotsFn)
r.HandleFunc("/bot/{id}", getBotsFn)

docs.AddDocs("GET", "/bots/{id}/reviews", "get_bot_reviews", "Get Bot Reviews", "Gets the reviews of a bot by its ID (names are not resolved by this endpoint)",
[]docs.Paramater{
Expand Down
18 changes: 15 additions & 3 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,25 @@ func (s BotStats) GetStats() (servers uint64, shards uint64, users uint64) {

// Handle float64
if serverFloat, ok := serverCount.(float64); ok {
serversParsed = uint64(serverFloat)
if serverFloat < 0 {
serversParsed = 0
} else {
serversParsed = uint64(serverFloat)
}
}
if shardFloat, ok := shardCount.(float64); ok {
shardsParsed = uint64(shardFloat)
if shardFloat < 0 {
shardsParsed = 0
} else {
shardsParsed = uint64(shardFloat)
}
}
if userFloat, ok := userCount.(float64); ok {
usersParsed = uint64(userFloat)
if userFloat < 0 {
userFloat = 0
} else {
usersParsed = uint64(userFloat)
}
}

// Handle float32
Expand Down

0 comments on commit d61cf78

Please sign in to comment.