Utils: Create Constant for HTTP status code 429

This commit is contained in:
mavolin 2020-05-07 18:49:07 +02:00
parent c7a392f836
commit e7c1c891fb
No known key found for this signature in database
GPG Key ID: D8681218EDF216DF
1 changed files with 6 additions and 3 deletions

View File

@ -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
}