Module twilight_http::request

source ·
Expand description

Typed request builders, multipart form support, a manual request builder for low-level request construction, and audit log reason support.

Request Builders

Requests are created in the form of builders. These can be awaited to receive a Response. Every route of Discord’s API has its own builder: creating a message is performed via the CreateMessage builder; updating a guild is done via UpdateGuild; and so on. All typed request builders are instantiated via the primary Client. When the library doesn’t yet support a new feature or fine-grained support is required, requests can be manually built via RequestBuilder.

Audit Log Reasons

Audit log reasons can be added to supported requests via the AuditLogReason trait:

use twilight_http::{client::Client, request::AuditLogReason};

let client = Client::new(std::env::var("DISCORD_TOKEN")?);
client
    .delete_ban(guild_id, user_id)
    .reason("ban expired")?
    .await?;

Modules

Request builders for interacting with scheduled events.

Structs

Retrieve information about the current OAuth authorization.
Get information about the gateway, optionally with additional information detailing the number of shards to use and sessions remaining.
Get information about the gateway, authenticated as a bot user.
Get a list of voice regions that can be used when creating a guild.
Builder to create a customized request.

Enums

Request method.

Traits

Attach a reason for a request.
Convert a typed request builder into a raw Request.