mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-03-23 10:29:30 +00:00
Utils: Create Constant for HTTP status code 429
This commit is contained in:
parent
c7a392f836
commit
e7c1c891fb
|
@ -7,13 +7,16 @@ import (
|
|||
"context"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/diamondburned/arikawa/utils/httputil/httpdriver"
|
||||
"github.com/diamondburned/arikawa/utils/json"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// StatusTooManyRequests is the HTTP status code discord sends on rate-limiting.
|
||||
const StatusTooManyRequests = 429
|
||||
|
||||
// Retries is the default attempts to retry if the API returns an error before
|
||||
// giving up. If the value is smaller than 1, then requests will retry forever.
|
||||
var Retries uint = 5
|
||||
|
@ -180,7 +183,7 @@ func (c *Client) Request(method, url string, opts ...RequestOption) (httpdriver.
|
|||
continue
|
||||
}
|
||||
|
||||
if status = r.GetStatus(); status == http.StatusTooManyRequests || status >= 500 {
|
||||
if status = r.GetStatus(); status == StatusTooManyRequests || status >= 500 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue