Struct twilight_http::client::Client [−][src]
pub struct Client { /* fields omitted */ }
Expand description
Twilight’s http client.
Almost all of the client methods require authentication, and as such, the client must be supplied with a Discord Token. Get yours here.
OAuth
To use Bearer tokens prefix the token with "Bearer "
, including the space
at the end like so:
use std::env;
use twilight_http::Client;
let bearer = env::var("BEARER_TOKEN")?;
let token = format!("Bearer {}", bearer);
let client = Client::new(token);
Using the client in multiple tasks
To use a client instance in multiple tasks, consider wrapping it in an
std::sync::Arc
or std::rc::Rc
.
Unauthorized behavior
When the client encounters an Unauthorized response it will take note that
the configured token is invalid. This may occur when the token has been
revoked or expired. When this happens, you must create a new client with the
new token. The client will no longer execute requests in order to
prevent API bans and will always return ErrorType::Unauthorized
.
Examples
Create a client called client
:
use twilight_http::Client;
let client = Client::new("my token".to_owned());
Use ClientBuilder
to create a client called client
, with a shorter
timeout:
use twilight_http::Client;
use std::time::Duration;
let client = Client::builder()
.token("my token".to_owned())
.timeout(Duration::from_secs(5))
.build();
All the examples on this page assume you have already created a client, and have named it
client
.
Implementations
Create a new hyper-rustls
or hyper-tls
backed client with a token.
Create a new builder to create a client.
Refer to its documentation for more information.
Retrieve an immutable reference to the token used by the client.
If the initial token provided is not prefixed with Bot
, it will be, and this method
reflects that.
Retrieve the ApplicationId
used by interaction methods.
Set a new ApplicationId
after building the client.
Returns the previous ID, if there was one.
Get the default AllowedMentions
for sent messages.
Get the Ratelimiter used by the client internally.
This will return None
only if ratelimit handling
has been explicitly disabled in the ClientBuilder
.
Get the audit log for a guild.
Examples
use twilight_model::id::GuildId;
let guild_id = GuildId::new(101).expect("non zero");
let audit_log = client
// not done
.audit_log(guild_id)
.exec()
.await?;
Retrieve the bans for a guild.
Examples
Retrieve the bans for guild 1
:
use twilight_model::id::GuildId;
let guild_id = GuildId::new(1).expect("non zero");
let bans = client.bans(guild_id).exec().await?;
Get information about a ban of a guild.
Includes the user banned and the reason.
Bans a user from a guild, optionally with the number of days’ worth of messages to delete and the reason.
Examples
Ban user 200
from guild 100
, deleting
1 day’s worth of messages, for the reason "memes"
:
use twilight_model::id::{GuildId, UserId};
let guild_id = GuildId::new(100).expect("non zero");
let user_id = UserId::new(200).expect("non zero");
client.create_ban(guild_id, user_id)
.delete_message_days(1)?
.reason("memes")?
.exec()
.await?;
Remove a ban from a user in a guild.
Examples
Unban user 200
from guild 100
:
use twilight_model::id::{GuildId, UserId};
let guild_id = GuildId::new(100).expect("non zero");
let user_id = UserId::new(200).expect("non zero");
client.delete_ban(guild_id, user_id).exec().await?;
Get a channel by its ID.
Examples
Get channel 100
:
let channel_id = ChannelId::new(100).expect("non zero");
let channel = client.channel(channel_id).exec().await?;
Delete a channel by ID.
Update a channel.
pub const fn follow_news_channel(
&self,
channel_id: ChannelId,
webhook_channel_id: ChannelId
) -> FollowNewsChannel<'_>
pub const fn follow_news_channel(
&self,
channel_id: ChannelId,
webhook_channel_id: ChannelId
) -> FollowNewsChannel<'_>
Follows a news channel by ChannelId
.
The type returned is FollowedChannel
.
Get the invites for a guild channel.
Requires the MANAGE_CHANNELS
permission. This method only works if
the channel is of type GuildChannel
.
Get channel messages, by ChannelId
.
Only one of after
, around
, and before
can be specified at a time.
Once these are specified, the type returned is GetChannelMessagesConfigured
.
If limit
is unspecified, the default set by Discord is 50.
Examples
use twilight_http::Client;
use twilight_model::id::{ChannelId, MessageId};
let client = Client::new("my token".to_owned());
let channel_id = ChannelId::new(123).expect("non zero");
let message_id = MessageId::new(234).expect("non zero");
let limit: u64 = 6;
let messages = client
.channel_messages(channel_id)
.before(message_id)
.limit(limit)?
.exec()
.await?;
Errors
Returns a GetChannelMessagesErrorType::LimitInvalid
error type if
the amount is less than 1 or greater than 100.
pub const fn delete_channel_permission(
&self,
channel_id: ChannelId
) -> DeleteChannelPermission<'_>
pub const fn update_channel_permission(
&self,
channel_id: ChannelId,
allow: Permissions,
deny: Permissions
) -> UpdateChannelPermission<'_>
pub const fn update_channel_permission(
&self,
channel_id: ChannelId,
allow: Permissions,
deny: Permissions
) -> UpdateChannelPermission<'_>
Update the permissions for a role or a user in a channel.
Examples:
Create permission overrides for a role to view the channel, but not send messages:
use twilight_model::guild::Permissions;
use twilight_model::id::{ChannelId, RoleId};
let channel_id = ChannelId::new(123).expect("non zero");
let allow = Permissions::VIEW_CHANNEL;
let deny = Permissions::SEND_MESSAGES;
let role_id = RoleId::new(432).expect("non zero");
client.update_channel_permission(channel_id, allow, deny)
.role(role_id)
.exec()
.await?;
Get all the webhooks of a channel.
Get information about the current user.
Get information about the current bot application.
Update the current user.
All parameters are optional. If the username is changed, it may cause the discriminator to be randomized.
pub const fn update_current_user_voice_state(
&self,
guild_id: GuildId,
channel_id: ChannelId
) -> UpdateCurrentUserVoiceState<'_>
pub const fn update_current_user_voice_state(
&self,
guild_id: GuildId,
channel_id: ChannelId
) -> UpdateCurrentUserVoiceState<'_>
Update the current user’s voice state.
All parameters are optional.
Caveats
channel_id
must currently point to a stage channel.- Current user must have already joined
channel_id
.
Get the current user’s connections.
Requires the connections
OAuth2
scope.
Returns a list of guilds for the current user.
Examples
Get the first 25 guilds with an ID after 300
and before
400
:
use twilight_model::id::GuildId;
let after = GuildId::new(300).expect("non zero");
let before = GuildId::new(400).expect("non zero");
let guilds = client.current_user_guilds()
.after(after)
.before(before)
.limit(25)?
.exec()
.await?;
pub const fn update_current_user_nick<'a>(
&'a self,
guild_id: GuildId,
nick: &'a str
) -> UpdateCurrentUserNick<'a>
👎 Deprecated since 0.7.2: use update_current_member instead
pub const fn update_current_user_nick<'a>(
&'a self,
guild_id: GuildId,
nick: &'a str
) -> UpdateCurrentUserNick<'a>
use update_current_member instead
Changes the user’s nickname in a guild.
Get the emojis for a guild, by the guild’s id.
Examples
Get the emojis for guild 100
:
let guild_id = GuildId::new(100).expect("non zero");
client.emojis(guild_id).exec().await?;
Get an emoji for a guild by the the guild’s ID and emoji’s ID.
Examples
Get emoji 100
from guild 50
:
let guild_id = GuildId::new(50).expect("non zero");
let emoji_id = EmojiId::new(100).expect("non zero");
client.emoji(guild_id, emoji_id).exec().await?;
pub const fn create_emoji<'a>(
&'a self,
guild_id: GuildId,
name: &'a str,
image: &'a str
) -> CreateEmoji<'a>
pub const fn create_emoji<'a>(
&'a self,
guild_id: GuildId,
name: &'a str,
image: &'a str
) -> CreateEmoji<'a>
Create an emoji in a guild.
The emoji must be a Data URI, in the form of data:image/{type};base64,{data}
where
{type}
is the image MIME type and {data}
is the base64-encoded image. Refer to the
discord docs for more information about image data.
Delete an emoji in a guild, by id.
Update an emoji in a guild, by id.
Get information about the gateway, optionally with additional information detailing the number of shards to use and sessions remaining.
Examples
Get the gateway connection URL without bot information:
let info = client.gateway().exec().await?;
Get the gateway connection URL with additional shard and session information, which requires specifying a bot token:
let info = client.gateway().authed().exec().await?.model().await?;
println!("URL: {}", info.url);
println!("Recommended shards to use: {}", info.shards);
Create a new request to create a guild.
The minimum length of the name is 2 UTF-16 characters and the maximum is 100 UTF-16 characters. This endpoint can only be used by bots in less than 10 guilds.
Errors
Returns a CreateGuildErrorType::NameInvalid
error type if the name
length is too short or too long.
Delete a guild permanently. The user must be the owner.
Update a guild.
All endpoints are optional. Refer to the discord docs for more information.
Leave a guild by id.
Get the channels in a guild.
pub fn create_guild_channel<'a>(
&'a self,
guild_id: GuildId,
name: &'a str
) -> Result<CreateGuildChannel<'a>, CreateGuildChannelError>
pub fn create_guild_channel<'a>(
&'a self,
guild_id: GuildId,
name: &'a str
) -> Result<CreateGuildChannel<'a>, CreateGuildChannelError>
Create a new request to create a guild channel.
All fields are optional except for name. The minimum length of the name is 1 UTF-16 character and the maximum is 100 UTF-16 characters.
Errors
Returns a CreateGuildChannelErrorType::NameInvalid
error type when
the length of the name is either fewer than 1 UTF-16 character or more
than 100 UTF-16 characters.
Returns a CreateGuildChannelErrorType::RateLimitPerUserInvalid
error
type when the seconds of the rate limit per user is more than 21600.
Returns a CreateGuildChannelErrorType::TopicInvalid
error type when
the length of the topic is more than 1024 UTF-16 characters.
pub const fn update_guild_channel_positions<'a>(
&'a self,
guild_id: GuildId,
channel_positions: &'a [Position]
) -> UpdateGuildChannelPositions<'a>
pub const fn update_guild_channel_positions<'a>(
&'a self,
guild_id: GuildId,
channel_positions: &'a [Position]
) -> UpdateGuildChannelPositions<'a>
Modify the positions of the channels.
The minimum amount of channels to modify, is a swap between two channels.
This function accepts an Iterator
of (ChannelId, u64)
. It also
accepts an Iterator
of Position
, which has extra fields.
Get the guild widget.
Refer to the discord docs for more information.
Modify the guild widget.
Get the guild’s integrations.
pub const fn delete_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> DeleteGuildIntegration<'_>
pub const fn delete_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> DeleteGuildIntegration<'_>
Delete an integration for a guild, by the integration’s id.
Get information about the invites of a guild.
Requires the MANAGE_GUILD
permission.
Get the members of a guild, by id.
The upper limit to this request is 1000. If more than 1000 members are needed, the requests must be chained. Discord defaults the limit to 1.
Examples
Get the first 500 members of guild 100
after user ID 3000
:
use twilight_model::id::{GuildId, UserId};
let guild_id = GuildId::new(100).expect("non zero");
let user_id = UserId::new(3000).expect("non zero");
let members = client.guild_members(guild_id).after(user_id).exec().await?;
Errors
Returns a GetGuildMembersErrorType::LimitInvalid
error type if the
limit is invalid.
pub const fn search_guild_members<'a>(
&'a self,
guild_id: GuildId,
query: &'a str
) -> SearchGuildMembers<'a>
pub const fn search_guild_members<'a>(
&'a self,
guild_id: GuildId,
query: &'a str
) -> SearchGuildMembers<'a>
Search the members of a specific guild by a query.
The upper limit to this request is 1000. Discord defaults the limit to 1.
Examples
Get the first 10 members of guild 100
matching Wumpus
:
use twilight_http::Client;
use twilight_model::id::GuildId;
let client = Client::new("my token".to_owned());
let guild_id = GuildId::new(100).expect("non zero");
let members = client.search_guild_members(guild_id, "Wumpus")
.limit(10)?
.exec()
.await?;
Errors
Returns a SearchGuildMembersErrorType::LimitInvalid
error type if
the limit is invalid.
Get a member of a guild, by their id.
pub const fn add_guild_member<'a>(
&'a self,
guild_id: GuildId,
user_id: UserId,
access_token: &'a str
) -> AddGuildMember<'a>
pub const fn add_guild_member<'a>(
&'a self,
guild_id: GuildId,
user_id: UserId,
access_token: &'a str
) -> AddGuildMember<'a>
Add a user to a guild.
An access token for the user with guilds.join
scope is required. All
other fields are optional. Refer to the discord docs for more
information.
Errors
Returns AddGuildMemberErrorType::NicknameInvalid
if the nickname is
too short or too long.
pub const fn remove_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> RemoveMember<'_>
pub const fn remove_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> RemoveMember<'_>
Kick a member from a guild.
pub const fn update_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> UpdateGuildMember<'_>
pub const fn update_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> UpdateGuildMember<'_>
Update a guild member.
All fields are optional. Refer to the discord docs for more information.
Examples
Update a member’s nickname to “pinky pie” and server mute them:
use std::env;
use twilight_http::Client;
use twilight_model::id::{GuildId, UserId};
let client = Client::new(env::var("DISCORD_TOKEN")?);
let member = client.update_guild_member(GuildId::new(1).expect("non zero"), UserId::new(2).expect("non zero"))
.mute(true)
.nick(Some("pinkie pie"))?
.exec()
.await?
.model()
.await?;
println!("user {} now has the nickname '{:?}'", member.user.id, member.nick);
Errors
Returns UpdateGuildMemberErrorType::NicknameInvalid
if the nickname length is too short or too
long.
Update the user’s member in a guild.
pub const fn add_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> AddRoleToMember<'_>
pub const fn add_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> AddRoleToMember<'_>
Add a role to a member in a guild.
Examples
In guild 1
, add role 2
to user 3
, for the reason "test"
:
use twilight_model::id::{GuildId, RoleId, UserId};
let guild_id = GuildId::new(1).expect("non zero");
let role_id = RoleId::new(2).expect("non zero");
let user_id = UserId::new(3).expect("non zero");
client.add_guild_member_role(guild_id, user_id, role_id)
.reason("test")?
.exec()
.await?;
pub const fn remove_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> RemoveRoleFromMember<'_>
pub const fn remove_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> RemoveRoleFromMember<'_>
Remove a role from a member in a guild, by id.
For public guilds, get the guild preview.
This works even if the user is not in the guild.
Get the counts of guild members to be pruned.
Begin a guild prune.
Refer to the discord docs for more information.
Get a guild’s vanity url, if there is one.
Get voice region data for the guild.
Can return VIP servers if the guild is VIP-enabled.
Get the webhooks of a guild.
Get the guild’s welcome screen.
pub const fn update_guild_welcome_screen(
&self,
guild_id: GuildId
) -> UpdateGuildWelcomeScreen<'_>
pub const fn update_guild_welcome_screen(
&self,
guild_id: GuildId
) -> UpdateGuildWelcomeScreen<'_>
Update the guild’s welcome screen.
Requires the MANAGE_GUILD
permission.
Get information about an invite by its code.
If with_counts
is called, the returned invite will contain
approximate member counts. If with_expiration
is called, it will
contain the expiration date.
Examples
let invite = client
.invite("code")
.with_counts()
.exec()
.await?;
Create an invite, with options.
Requires the CREATE_INVITE
permission.
Examples
let channel_id = ChannelId::new(123).expect("non zero");
let invite = client
.create_invite(channel_id)
.max_uses(3)?
.exec()
.await?;
Delete an invite by its code.
Requires the MANAGE_CHANNELS
permission on the channel this invite
belongs to, or MANAGE_GUILD
to remove any invite across the guild.
Send a message to a channel.
Example
let channel_id = ChannelId::new(123).expect("non zero");
let message = client
.create_message(channel_id)
.content("Twilight is best pony")?
.tts(true)
.exec()
.await?;
Errors
The method content
returns
CreateMessageErrorType::ContentInvalid
if the content is over 2000
UTF-16 characters.
The method embeds
returns
CreateMessageErrorType::EmbedTooLarge
if the length of the embed
is over 6000 characters.
pub const fn delete_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteMessage<'_>
pub const fn delete_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteMessage<'_>
pub const fn delete_messages<'a>(
&'a self,
channel_id: ChannelId,
message_ids: &'a [MessageId]
) -> DeleteMessages<'a>
pub const fn delete_messages<'a>(
&'a self,
channel_id: ChannelId,
message_ids: &'a [MessageId]
) -> DeleteMessages<'a>
Delete messages by ChannelId
and Vec<MessageId
>.
The vec count can be between 2 and 100. If the supplied MessageId
s are invalid, they
still count towards the lower and upper limits. This method will not delete messages older
than two weeks. Refer to the discord docs for more information.
pub const fn update_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> UpdateMessage<'_>
pub const fn update_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> UpdateMessage<'_>
Update a message by ChannelId
and MessageId
.
You can pass None
to any of the methods to remove the associated field.
For example, if you have a message with an embed you want to remove, you can
use .[embed](None)
to remove the embed.
Examples
Replace the content with "test update"
:
use twilight_http::Client;
use twilight_model::id::{ChannelId, MessageId};
let client = Client::new("my token".to_owned());
client.update_message(ChannelId::new(1).expect("non zero"), MessageId::new(2).expect("non zero"))
.content(Some("test update"))?
.exec()
.await?;
Remove the message’s content:
client.update_message(ChannelId::new(1).expect("non zero"), MessageId::new(2).expect("non zero"))
.content(None)?
.exec()
.await?;
pub const fn crosspost_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> CrosspostMessage<'_>
pub const fn crosspost_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> CrosspostMessage<'_>
Create a new pin in a channel, by ID.
Delete a pin in a channel, by ID.
pub const fn reactions<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> GetReactions<'a>
pub const fn reactions<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> GetReactions<'a>
Get a list of users that reacted to a message with an emoji
.
This endpoint is limited to 100 users maximum, so if a message has more than 100 reactions, requests must be chained until all reactions are retrieved.
pub const fn create_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> CreateReaction<'a>
pub const fn create_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> CreateReaction<'a>
Create a reaction in a ChannelId
on a MessageId
.
The reaction must be a variant of RequestReactionType
.
Examples
let channel_id = ChannelId::new(123).expect("non zero");
let message_id = MessageId::new(456).expect("non zero");
let emoji = RequestReactionType::Unicode { name: "🌃" };
let reaction = client
.create_reaction(channel_id, message_id, &emoji)
.exec()
.await?;
pub const fn delete_current_user_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> DeleteReaction<'a>
pub const fn delete_current_user_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> DeleteReaction<'a>
Delete the current user’s (@me
) reaction on a message.
pub const fn delete_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>,
user_id: UserId
) -> DeleteReaction<'a>
pub const fn delete_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>,
user_id: UserId
) -> DeleteReaction<'a>
Delete a reaction by a user on a message.
pub const fn delete_all_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> DeleteAllReaction<'a>
pub const fn delete_all_reaction<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
emoji: &'a RequestReactionType<'a>
) -> DeleteAllReaction<'a>
Remove all reactions on a message of an emoji.
pub const fn delete_all_reactions(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteAllReactions<'_>
pub const fn delete_all_reactions(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteAllReactions<'_>
Delete all reactions by all users on a message.
Fire a Typing Start event in the channel.
Create a group DM.
This endpoint is limited to 10 active group DMs.
Get the roles of a guild.
Create a role in a guild.
Examples
use twilight_model::id::GuildId;
let guild_id = GuildId::new(234).expect("non zero");
client.create_role(guild_id)
.color(0xd90083)
.name("Bright Pink")
.exec()
.await?;
Delete a role in a guild, by id.
Update a role by guild id and its id.
pub const fn update_role_positions<'a>(
&'a self,
guild_id: GuildId,
roles: &'a [(RoleId, u64)]
) -> UpdateRolePositions<'a>
pub const fn update_role_positions<'a>(
&'a self,
guild_id: GuildId,
roles: &'a [(RoleId, u64)]
) -> UpdateRolePositions<'a>
Modify the position of the roles.
The minimum amount of roles to modify, is a swap between two roles.
pub fn create_stage_instance<'a>(
&'a self,
channel_id: ChannelId,
topic: &'a str
) -> Result<CreateStageInstance<'a>, CreateStageInstanceError>
pub fn create_stage_instance<'a>(
&'a self,
channel_id: ChannelId,
topic: &'a str
) -> Result<CreateStageInstance<'a>, CreateStageInstanceError>
Create a new stage instance associated with a stage channel.
Requires the user to be a moderator of the stage channel.
Errors
Returns a CreateStageInstanceError
of type InvalidTopic
when the
topic is not between 1 and 120 characters in length.
Gets the stage instance associated with a stage channel, if it exists.
Update fields of an existing stage instance.
Requires the user to be a moderator of the stage channel.
Delete the stage instance of a stage channel.
Requires the user to be a moderator of the stage channel.
pub fn create_guild_from_template<'a>(
&'a self,
template_code: &'a str,
name: &'a str
) -> Result<CreateGuildFromTemplate<'a>, CreateGuildFromTemplateError>
pub fn create_guild_from_template<'a>(
&'a self,
template_code: &'a str,
name: &'a str
) -> Result<CreateGuildFromTemplate<'a>, CreateGuildFromTemplateError>
Create a new guild based on a template.
This endpoint can only be used by bots in less than 10 guilds.
Errors
Returns a CreateGuildFromTemplateErrorType::NameInvalid
error type
if the name is invalid.
pub fn create_template<'a>(
&'a self,
guild_id: GuildId,
name: &'a str
) -> Result<CreateTemplate<'a>, CreateTemplateError>
pub fn create_template<'a>(
&'a self,
guild_id: GuildId,
name: &'a str
) -> Result<CreateTemplate<'a>, CreateTemplateError>
Create a template from the current state of the guild.
Requires the MANAGE_GUILD
permission. The name must be at least 1 and
at most 100 characters in length.
Errors
Returns a CreateTemplateErrorType::NameInvalid
error type if the
name is invalid.
pub const fn delete_template<'a>(
&'a self,
guild_id: GuildId,
template_code: &'a str
) -> DeleteTemplate<'a>
pub const fn delete_template<'a>(
&'a self,
guild_id: GuildId,
template_code: &'a str
) -> DeleteTemplate<'a>
Delete a template by ID and code.
Get a template by its code.
Get a list of templates in a guild, by ID.
pub const fn sync_template<'a>(
&'a self,
guild_id: GuildId,
template_code: &'a str
) -> SyncTemplate<'a>
pub const fn sync_template<'a>(
&'a self,
guild_id: GuildId,
template_code: &'a str
) -> SyncTemplate<'a>
Sync a template to the current state of the guild, by ID and code.
pub const fn update_template<'a>(
&'a self,
guild_id: GuildId,
template_code: &'a str
) -> UpdateTemplate<'a>
pub const fn update_template<'a>(
&'a self,
guild_id: GuildId,
template_code: &'a str
) -> UpdateTemplate<'a>
Update the template’s metadata, by ID and code.
Returns all active threads in the channel.
Includes public and private threads. Threads are ordered by their ID in descending order.
pub const fn add_thread_member(
&self,
channel_id: ChannelId,
user_id: UserId
) -> AddThreadMember<'_>
pub const fn add_thread_member(
&self,
channel_id: ChannelId,
user_id: UserId
) -> AddThreadMember<'_>
Add another member to a thread.
Requires the ability to send messages in the thread, and that the thread is not archived.
pub fn create_thread<'a>(
&'a self,
channel_id: ChannelId,
name: &'a str,
kind: ChannelType
) -> Result<CreateThread<'_>, ThreadValidationError>
pub fn create_thread<'a>(
&'a self,
channel_id: ChannelId,
name: &'a str,
kind: ChannelType
) -> Result<CreateThread<'_>, ThreadValidationError>
Start a thread that is not connected to a message.
Values of ThreeDays
and Week
require the guild to be boosted.
The guild’s features will indicate if a guild is able to use these
settings.
To make a GuildPrivateThread
, the guild must also have the
PRIVATE_THREADS
feature.
pub fn create_thread_from_message<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
name: &'a str
) -> Result<CreateThreadFromMessage<'_>, ThreadValidationError>
pub fn create_thread_from_message<'a>(
&'a self,
channel_id: ChannelId,
message_id: MessageId,
name: &'a str
) -> Result<CreateThreadFromMessage<'_>, ThreadValidationError>
Create a new thread from an existing message.
When called on a GuildText
channel, this creates a
GuildPublicThread
.
When called on a GuildNews
channel, this creates a
GuildNewsThread
.
Values of ThreeDays
and Week
require the guild to be boosted.
The guild’s features will indicate if a guild is able to use these
settings.
The thread’s ID will be the same as its parent message. This ensures only one thread can be created per message.
Add the current user to a thread.
pub const fn joined_private_archived_threads(
&self,
channel_id: ChannelId
) -> GetJoinedPrivateArchivedThreads<'_>
pub const fn joined_private_archived_threads(
&self,
channel_id: ChannelId
) -> GetJoinedPrivateArchivedThreads<'_>
Returns archived private threads in the channel that the current user has joined.
Threads are ordered by their ID in descending order.
Remove the current user from a thread.
Requires that the thread is not archived.
pub const fn private_archived_threads(
&self,
channel_id: ChannelId
) -> GetPrivateArchivedThreads<'_>
pub const fn private_archived_threads(
&self,
channel_id: ChannelId
) -> GetPrivateArchivedThreads<'_>
Returns archived private threads in the channel.
Requires both READ_MESSAGE_HISTORY
and MANAGE_THREADS
.
pub const fn public_archived_threads(
&self,
channel_id: ChannelId
) -> GetPublicArchivedThreads<'_>
pub const fn public_archived_threads(
&self,
channel_id: ChannelId
) -> GetPublicArchivedThreads<'_>
Returns archived public threads in the channel.
Requires the READ_MESSAGE_HISTORY
permission.
Threads are ordered by archive_timestamp
in descending order.
When called in a GuildText
channel, returns GuildPublicThread
s.
When called in a GuildNews
channel, returns GuildNewsThread
s.
pub const fn remove_thread_member(
&self,
channel_id: ChannelId,
user_id: UserId
) -> RemoveThreadMember<'_>
pub const fn remove_thread_member(
&self,
channel_id: ChannelId,
user_id: UserId
) -> RemoveThreadMember<'_>
Remove another member from a thread.
Requires that the thread is not archived.
Requires the MANAGE_THREADS
permission, unless both the thread is a
GuildPrivateThread
, and the current user is the creator of the
thread.
pub const fn thread_member(
&self,
channel_id: ChannelId,
user_id: UserId
) -> GetThreadMember<'_>
pub const fn thread_member(
&self,
channel_id: ChannelId,
user_id: UserId
) -> GetThreadMember<'_>
Returns a ThreadMember
in a thread.
Returns the ThreadMember
s of the thread.
Update a thread.
All fields are optional. The minimum length of the name is 1 UTF-16 characters and the maximum is 100 UTF-16 characters.
pub const fn update_user_voice_state(
&self,
guild_id: GuildId,
user_id: UserId,
channel_id: ChannelId
) -> UpdateUserVoiceState<'_>
pub const fn update_user_voice_state(
&self,
guild_id: GuildId,
user_id: UserId,
channel_id: ChannelId
) -> UpdateUserVoiceState<'_>
Update another user’s voice state.
Caveats
channel_id
must currently point to a stage channel.- User must already have joined
channel_id
.
Get a list of voice regions that can be used when creating a guild.
Get a webhook by ID.
pub const fn create_webhook<'a>(
&'a self,
channel_id: ChannelId,
name: &'a str
) -> CreateWebhook<'a>
pub const fn create_webhook<'a>(
&'a self,
channel_id: ChannelId,
name: &'a str
) -> CreateWebhook<'a>
Create a webhook in a channel.
Examples
let channel_id = ChannelId::new(123).expect("non zero");
let webhook = client
.create_webhook(channel_id, "Twily Bot")
.exec()
.await?;
Delete a webhook by its ID.
Update a webhook by ID.
pub const fn update_webhook_with_token<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str
) -> UpdateWebhookWithToken<'a>
pub const fn update_webhook_with_token<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str
) -> UpdateWebhookWithToken<'a>
Update a webhook, with a token, by ID.
pub const fn execute_webhook<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str
) -> ExecuteWebhook<'a>
pub const fn execute_webhook<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str
) -> ExecuteWebhook<'a>
pub const fn webhook_message<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str,
message_id: MessageId
) -> GetWebhookMessage<'a>
pub const fn webhook_message<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str,
message_id: MessageId
) -> GetWebhookMessage<'a>
pub const fn update_webhook_message<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str,
message_id: MessageId
) -> UpdateWebhookMessage<'a>
pub const fn update_webhook_message<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str,
message_id: MessageId
) -> UpdateWebhookMessage<'a>
Update a message executed by a webhook.
Examples
use twilight_model::id::{MessageId, WebhookId};
client.update_webhook_message(WebhookId::new(1).expect("non zero"), "token here", MessageId::new(2).expect("non zero"))
.content(Some("new message content"))?
.exec()
.await?;
pub const fn delete_webhook_message<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str,
message_id: MessageId
) -> DeleteWebhookMessage<'a>
pub const fn delete_webhook_message<'a>(
&'a self,
webhook_id: WebhookId,
token: &'a str,
message_id: MessageId
) -> DeleteWebhookMessage<'a>
Delete a message executed by a webhook.
Examples
use twilight_model::id::{MessageId, WebhookId};
client
.delete_webhook_message(WebhookId::new(1).expect("non zero"), "token here", MessageId::new(2).expect("non zero"))
.exec()
.await?;
pub const fn interaction_callback<'a>(
&'a self,
interaction_id: InteractionId,
interaction_token: &'a str,
response: &'a InteractionResponse
) -> InteractionCallback<'a>
pub const fn interaction_callback<'a>(
&'a self,
interaction_id: InteractionId,
interaction_token: &'a str,
response: &'a InteractionResponse
) -> InteractionCallback<'a>
Respond to an interaction, by ID and token.
For variants of InteractionResponse
that contain a CallbackData
,
there is an associated builder in the twilight-util
crate.
pub fn get_interaction_original<'a>(
&'a self,
interaction_token: &'a str
) -> Result<GetOriginalResponse<'a>, InteractionError>
pub fn get_interaction_original<'a>(
&'a self,
interaction_token: &'a str
) -> Result<GetOriginalResponse<'a>, InteractionError>
Get the original message, by its token.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn update_interaction_original<'a>(
&'a self,
interaction_token: &'a str
) -> Result<UpdateOriginalResponse<'a>, InteractionError>
pub fn update_interaction_original<'a>(
&'a self,
interaction_token: &'a str
) -> Result<UpdateOriginalResponse<'a>, InteractionError>
Edit the original message, by its token.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn followup_message<'a>(
&'a self,
interaction_token: &'a str,
message_id: MessageId
) -> Result<GetFollowupMessage<'a>, InteractionError>
pub fn followup_message<'a>(
&'a self,
interaction_token: &'a str,
message_id: MessageId
) -> Result<GetFollowupMessage<'a>, InteractionError>
Get a followup message of an interaction.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn delete_interaction_original<'a>(
&'a self,
interaction_token: &'a str
) -> Result<DeleteOriginalResponse<'a>, InteractionError>
pub fn delete_interaction_original<'a>(
&'a self,
interaction_token: &'a str
) -> Result<DeleteOriginalResponse<'a>, InteractionError>
Delete the original message, by its token.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn create_followup_message<'a>(
&'a self,
interaction_token: &'a str
) -> Result<CreateFollowupMessage<'a>, InteractionError>
pub fn create_followup_message<'a>(
&'a self,
interaction_token: &'a str
) -> Result<CreateFollowupMessage<'a>, InteractionError>
Create a followup message, by an interaction token.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn update_followup_message<'a>(
&'a self,
interaction_token: &'a str,
message_id: MessageId
) -> Result<UpdateFollowupMessage<'a>, InteractionError>
pub fn update_followup_message<'a>(
&'a self,
interaction_token: &'a str,
message_id: MessageId
) -> Result<UpdateFollowupMessage<'a>, InteractionError>
Edit a followup message, by an interaction token.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn delete_followup_message<'a>(
&'a self,
interaction_token: &'a str,
message_id: MessageId
) -> Result<DeleteFollowupMessage<'a>, InteractionError>
pub fn delete_followup_message<'a>(
&'a self,
interaction_token: &'a str,
message_id: MessageId
) -> Result<DeleteFollowupMessage<'a>, InteractionError>
Delete a followup message by interaction token and the message’s ID.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn create_guild_command<'a>(
&'a self,
guild_id: GuildId,
name: &'a str
) -> Result<CreateGuildCommand<'a>, InteractionError>
pub fn create_guild_command<'a>(
&'a self,
guild_id: GuildId,
name: &'a str
) -> Result<CreateGuildCommand<'a>, InteractionError>
Create a new command in a guild.
The name must be between 1 and 32 characters in length. Creating a guild command with the same name as an already-existing guild command in the same guild will overwrite the old command. See the discord docs for more information.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
Returns an InteractionErrorType::CommandNameValidationFailed
error type if the command name is not between 1 and 32 characters.
pub fn get_guild_command(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<GetGuildCommand<'_>, InteractionError>
pub fn get_guild_command(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<GetGuildCommand<'_>, InteractionError>
Fetch a guild command for your application.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn get_guild_commands(
&self,
guild_id: GuildId
) -> Result<GetGuildCommands<'_>, InteractionError>
pub fn get_guild_commands(
&self,
guild_id: GuildId
) -> Result<GetGuildCommands<'_>, InteractionError>
Fetch all commands for a guild, by ID.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn update_guild_command(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<UpdateGuildCommand<'_>, InteractionError>
pub fn update_guild_command(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<UpdateGuildCommand<'_>, InteractionError>
Edit a command in a guild, by ID.
You must specify a name and description. See the discord docs for more information.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn delete_guild_command(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<DeleteGuildCommand<'_>, InteractionError>
pub fn delete_guild_command(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<DeleteGuildCommand<'_>, InteractionError>
Delete a command in a guild, by ID.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn set_guild_commands<'a>(
&'a self,
guild_id: GuildId,
commands: &'a [Command]
) -> Result<SetGuildCommands<'a>, InteractionError>
pub fn set_guild_commands<'a>(
&'a self,
guild_id: GuildId,
commands: &'a [Command]
) -> Result<SetGuildCommands<'a>, InteractionError>
Set a guild’s commands.
This method is idempotent: it can be used on every start, without being ratelimited if there aren’t changes to the commands.
The Command
struct has an associated builder in the
twilight-util
crate.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn create_global_command<'a>(
&'a self,
name: &'a str
) -> Result<CreateGlobalCommand<'a>, InteractionError>
pub fn create_global_command<'a>(
&'a self,
name: &'a str
) -> Result<CreateGlobalCommand<'a>, InteractionError>
Create a new global command.
The name must be between 1 and 32 characters in length. Creating a command with the same name as an already-existing global command will overwrite the old command. See the discord docs for more information.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
Returns an InteractionErrorType::CommandNameValidationFailed
error type if the command name is not between 1 and 32 characters.
pub fn get_global_command(
&self,
command_id: CommandId
) -> Result<GetGlobalCommand<'_>, InteractionError>
pub fn get_global_command(
&self,
command_id: CommandId
) -> Result<GetGlobalCommand<'_>, InteractionError>
Fetch a global command for your application.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
Fetch all global commands for your application.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn update_global_command(
&self,
command_id: CommandId
) -> Result<UpdateGlobalCommand<'_>, InteractionError>
pub fn update_global_command(
&self,
command_id: CommandId
) -> Result<UpdateGlobalCommand<'_>, InteractionError>
Edit a global command, by ID.
You must specify a name and description. See the discord docs for more information.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn delete_global_command(
&self,
command_id: CommandId
) -> Result<DeleteGlobalCommand<'_>, InteractionError>
pub fn delete_global_command(
&self,
command_id: CommandId
) -> Result<DeleteGlobalCommand<'_>, InteractionError>
Delete a global command, by ID.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn set_global_commands<'a>(
&'a self,
commands: &'a [Command]
) -> Result<SetGlobalCommands<'a>, InteractionError>
pub fn set_global_commands<'a>(
&'a self,
commands: &'a [Command]
) -> Result<SetGlobalCommands<'a>, InteractionError>
Set global commands.
This method is idempotent: it can be used on every start, without being ratelimited if there aren’t changes to the commands.
The Command
struct has an associated builder in the
twilight-util
crate.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn get_command_permissions(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<GetCommandPermissions<'_>, InteractionError>
pub fn get_command_permissions(
&self,
guild_id: GuildId,
command_id: CommandId
) -> Result<GetCommandPermissions<'_>, InteractionError>
Fetch command permissions for a command from the current application in a guild.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn get_guild_command_permissions(
&self,
guild_id: GuildId
) -> Result<GetGuildCommandPermissions<'_>, InteractionError>
pub fn get_guild_command_permissions(
&self,
guild_id: GuildId
) -> Result<GetGuildCommandPermissions<'_>, InteractionError>
Fetch command permissions for all commands from the current application in a guild.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn update_command_permissions<'a>(
&'a self,
guild_id: GuildId,
command_id: CommandId,
permissions: &'a [CommandPermissions]
) -> Result<UpdateCommandPermissions<'a>, InteractionError>
pub fn update_command_permissions<'a>(
&'a self,
guild_id: GuildId,
command_id: CommandId,
permissions: &'a [CommandPermissions]
) -> Result<UpdateCommandPermissions<'a>, InteractionError>
Update command permissions for a single command in a guild.
This overwrites the command permissions so the full set of permissions have to be sent every time.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
pub fn set_command_permissions<'a>(
&'a self,
guild_id: GuildId,
permissions: &'a [(CommandId, CommandPermissions)]
) -> Result<SetCommandPermissions<'a>, InteractionError>
pub fn set_command_permissions<'a>(
&'a self,
guild_id: GuildId,
permissions: &'a [(CommandId, CommandPermissions)]
) -> Result<SetCommandPermissions<'a>, InteractionError>
Update command permissions for all commands in a guild.
This overwrites the command permissions so the full set of permissions have to be sent every time.
Errors
Returns an InteractionErrorType::ApplicationIdNotPresent
error type if an application ID has not been configured via
Client::set_application_id
.
Returns an InteractionErrorType::TooManyCommands
error type if too
many commands have been provided. The maximum amount is defined by
InteractionError::GUILD_COMMAND_LIMIT
.
Returns a single sticker by its ID.
Examples
use twilight_http::Client;
use twilight_model::channel::message::sticker::StickerId;
let client = Client::new("my token".to_owned());
let id = StickerId::new(123).expect("non zero");
let sticker = client.sticker(id).exec().await?.model().await?;
println!("{:#?}", sticker);
Returns a list of sticker packs available to Nitro subscribers.
Examples
use twilight_http::Client;
let client = Client::new("my token".to_owned());
let packs = client.nitro_sticker_packs().exec().await?.model().await?;
println!("{}", packs.sticker_packs.len());
Returns a list of stickers in a guild.
Examples
use twilight_http::Client;
use twilight_model::{
channel::message::sticker::StickerId,
id::GuildId,
};
let client = Client::new("my token".to_owned());
let guild_id = GuildId::new(1).expect("non zero");
let stickers = client
.guild_stickers(guild_id)
.exec()
.await?
.models()
.await?;
println!("{}", stickers.len());
pub const fn guild_sticker(
&self,
guild_id: GuildId,
sticker_id: StickerId
) -> GetGuildSticker<'_>
pub const fn guild_sticker(
&self,
guild_id: GuildId,
sticker_id: StickerId
) -> GetGuildSticker<'_>
Returns a guild sticker by the guild’s ID and the sticker’s ID.
Examples
use twilight_http::Client;
use twilight_model::{
channel::message::sticker::StickerId,
id::GuildId,
};
let client = Client::new("my token".to_owned());
let guild_id = GuildId::new(1).expect("non zero");
let sticker_id = StickerId::new(2).expect("non zero");
let sticker = client
.guild_sticker(guild_id, sticker_id)
.exec()
.await?
.model()
.await?;
println!("{:#?}", sticker);
pub fn create_guild_sticker<'a>(
&'a self,
guild_id: GuildId,
name: &'a str,
description: &'a str,
tags: &'a str,
file: &'a [u8]
) -> Result<CreateGuildSticker<'_>, StickerValidationError>
pub fn create_guild_sticker<'a>(
&'a self,
guild_id: GuildId,
name: &'a str,
description: &'a str,
tags: &'a str,
file: &'a [u8]
) -> Result<CreateGuildSticker<'_>, StickerValidationError>
Creates a sticker in a guild, and returns the created sticker.
Examples
use twilight_http::Client;
use twilight_model::{
channel::message::sticker::StickerId,
id::GuildId,
};
let client = Client::new("my token".to_owned());
let guild_id = GuildId::new(1).expect("non zero");
let sticker = client
.create_guild_sticker(
guild_id,
&"sticker name",
&"sticker description",
&"sticker,tags",
&[23,23,23,23]
)?
.exec()
.await?
.model()
.await?;
println!("{:#?}", sticker);
pub const fn update_guild_sticker(
&self,
guild_id: GuildId,
sticker_id: StickerId
) -> UpdateGuildSticker<'_>
pub const fn update_guild_sticker(
&self,
guild_id: GuildId,
sticker_id: StickerId
) -> UpdateGuildSticker<'_>
Updates a sticker in a guild, and returns the updated sticker.
Examples
use twilight_http::Client;
use twilight_model::{
channel::message::sticker::StickerId,
id::GuildId,
};
let client = Client::new("my token".to_owned());
let guild_id = GuildId::new(1).expect("non zero");
let sticker_id = StickerId::new(2).expect("non zero");
let sticker = client
.update_guild_sticker(guild_id, sticker_id)
.description("new description")?
.exec()
.await?
.model()
.await?;
println!("{:#?}", sticker);
pub const fn delete_guild_sticker(
&self,
guild_id: GuildId,
sticker_id: StickerId
) -> DeleteGuildSticker<'_>
pub const fn delete_guild_sticker(
&self,
guild_id: GuildId,
sticker_id: StickerId
) -> DeleteGuildSticker<'_>
Deletes a guild sticker by the ID of the guild and its ID.
Examples
use twilight_http::Client;
use twilight_model::{
channel::message::sticker::StickerId,
id::GuildId,
};
let client = Client::new("my token".to_owned());
let guild_id = GuildId::new(1).expect("non zero");
let sticker_id = StickerId::new(2).expect("non zero");
client
.delete_guild_sticker(guild_id, sticker_id)
.exec()
.await?;
pub fn request<T>(&self, request: Request) -> ResponseFuture<T>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
pub fn request<T>(&self, request: Request) -> ResponseFuture<T>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
Execute a request, returning a future resolving to a Response
.
Errors
Returns an ErrorType::Unauthorized
error type if the configured
token has become invalid due to expiration, revocation, etc.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more