Module http

Source
Expand description

The HTTP module which provides functions for performing requests to endpoints in Discord’s API.

An important function of the REST API is ratelimiting. Requests to endpoints are ratelimited to prevent spam, and once ratelimited Discord will stop performing requests. The library implements protection to pre-emptively ratelimit, to ensure that no wasted requests are made.

The HTTP module comprises of two types of requests:

  • REST API requests, which require an authorization token;
  • Other requests, which do not require an authorization token.

The former require a Client to have logged in, while the latter may be made regardless of any other usage of the library.

If a request spuriously fails, it will be retried once.

Note that you may want to perform requests through a models’ instance methods where possible, as they each offer different levels of a high-level interface to the HTTP module.

Structs§

DiscordJsonError
DiscordJsonSingleError
ErrorResponse
Http
Note: For all member functions that return a Result, the Error kind will be either Error::Http or Error::Json.
HttpBuilder
A builder for the underlying Http client that performs requests to Discord’s HTTP API
Multipart
Holder for multipart body. Contains upload data, multipart fields, and payload_json for creating requests with attachments.
Ratelimit
A set of data containing information about the ratelimits for a particular RatelimitingBucket, which is stored in Http.
RatelimitInfo
Passed to the Ratelimiter::set_ratelimit_callback callback. If using Client, that callback is initialized to call the EventHandler::ratelimit() method.
Ratelimiter
Ratelimiter for requests to the Discord API.
RatelimitingBucket
Used to group requests together for ratelimiting.
Request
StatusCode
An HTTP status code (status-code in RFC 7230 et al.).
Typing
A struct to start typing in a Channel for an indefinite period of time.

Enums§

GuildPagination
Representation of the method of a query to send for the Http::get_guilds function.
HttpError
LightMethod
An method used for ratelimiting special routes.
MessagePagination
MultipartUpload
Route
UserPagination
Representation of the method of a query to send for the Http::get_scheduled_event_users and Http::get_bans functions.

Traits§

CacheHttp
This trait will be required by functions that need Http and can optionally use a Cache to potentially avoid REST-requests.

Functions§

deserialize_errors

Type Aliases§

RequestBuilderDeprecated