Struct twilight_http::client::Client [−][src]
pub struct Client { /* fields omitted */ }
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);
Cloning
The client internally wraps its data within an Arc. This means that the client can be cloned and passed around tasks and threads cheaply.
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 Error::Unauthorized
.
Examples
Create a client called client
:
use twilight_http::Client; let client = Client::new("my token");
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") .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
impl Client
[src]
impl Client
[src]pub fn new(token: impl Into<String>) -> Self
[src]
pub fn new(token: impl Into<String>) -> Self
[src]Create a new hyper-rustls
or hyper-tls
backed client with a token.
pub fn builder() -> ClientBuilder
[src]
pub fn builder() -> ClientBuilder
[src]Create a new builder to create a client.
Refer to its documentation for more information.
pub fn token(&self) -> Option<&str>
[src]
pub fn token(&self) -> Option<&str>
[src]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.
pub fn default_allowed_mentions(&self) -> Option<AllowedMentions>
[src]
pub fn default_allowed_mentions(&self) -> Option<AllowedMentions>
[src]Get the default allowed mentions for sent messages.
Refer to allowed_mentions
for more information.
pub fn ratelimiter(&self) -> Option<Ratelimiter>
[src]
pub fn ratelimiter(&self) -> Option<Ratelimiter>
[src]Get the Ratelimiter used by the client internally.
This will return None
only if ratelimit handling
has been explicitly disabled in the ClientBuilder
.
pub fn audit_log(&self, guild_id: GuildId) -> GetAuditLog<'_>ⓘNotable traits for GetAuditLog<'_>
impl Future for GetAuditLog<'_> type Output = Result<Option<AuditLog>>;
[src]
pub fn audit_log(&self, guild_id: GuildId) -> GetAuditLog<'_>ⓘNotable traits for GetAuditLog<'_>
impl Future for GetAuditLog<'_> type Output = Result<Option<AuditLog>>;
[src]Get the audit log for a guild.
Examples
use twilight_model::id::GuildId; let guild_id = GuildId(101); let audit_log = client // not done .audit_log(guild_id) .await?;
pub fn bans(&self, guild_id: GuildId) -> GetBans<'_>ⓘ
[src]
pub fn bans(&self, guild_id: GuildId) -> GetBans<'_>ⓘ
[src]Retrieve the bans for a guild.
Examples
Retrieve the bans for guild 1
:
use twilight_model::id::GuildId; let guild_id = GuildId(1); let bans = client.bans(guild_id).await?;
pub fn ban(&self, guild_id: GuildId, user_id: UserId) -> GetBan<'_>ⓘ
[src]
pub fn ban(&self, guild_id: GuildId, user_id: UserId) -> GetBan<'_>ⓘ
[src]Get information about a ban of a guild.
Includes the user banned and the reason.
pub fn create_ban(&self, guild_id: GuildId, user_id: UserId) -> CreateBan<'_>ⓘ
[src]
pub fn create_ban(&self, guild_id: GuildId, user_id: UserId) -> CreateBan<'_>ⓘ
[src]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(100); let user_id = UserId(200); client.create_ban(guild_id, user_id) .delete_message_days(1)? .reason("memes")? .await?;
pub fn delete_ban(&self, guild_id: GuildId, user_id: UserId) -> DeleteBan<'_>ⓘ
[src]
pub fn delete_ban(&self, guild_id: GuildId, user_id: UserId) -> DeleteBan<'_>ⓘ
[src]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(100); let user_id = UserId(200); client.delete_ban(guild_id, user_id).await?;
pub fn channel(&self, channel_id: ChannelId) -> GetChannel<'_>ⓘNotable traits for GetChannel<'_>
impl Future for GetChannel<'_> type Output = Result<Option<Channel>>;
[src]
pub fn channel(&self, channel_id: ChannelId) -> GetChannel<'_>ⓘNotable traits for GetChannel<'_>
impl Future for GetChannel<'_> type Output = Result<Option<Channel>>;
[src]Get a channel by its ID.
Examples
Get channel 100
:
let channel_id = ChannelId(100); let channel = client.channel(channel_id).await?;
pub fn delete_channel(&self, channel_id: ChannelId) -> DeleteChannel<'_>ⓘNotable traits for DeleteChannel<'_>
impl Future for DeleteChannel<'_> type Output = Result<Channel>;
[src]
pub fn delete_channel(&self, channel_id: ChannelId) -> DeleteChannel<'_>ⓘNotable traits for DeleteChannel<'_>
impl Future for DeleteChannel<'_> type Output = Result<Channel>;
[src]Delete a channel by ID.
pub fn update_channel(&self, channel_id: ChannelId) -> UpdateChannel<'_>ⓘNotable traits for UpdateChannel<'_>
impl Future for UpdateChannel<'_> type Output = Result<Channel>;
[src]
pub fn update_channel(&self, channel_id: ChannelId) -> UpdateChannel<'_>ⓘNotable traits for UpdateChannel<'_>
impl Future for UpdateChannel<'_> type Output = Result<Channel>;
[src]Update a channel.
All fields are optional. The minimum length of the name is 2 UTF-16 characters and the maximum is 100 UTF-16 characters.
Errors
Returns a UpdateChannelError::NameInvalid
when the length of the name is either fewer
than 2 UTF-16 characters or more than 100 UTF-16 characters.
Returns a UpdateChannelError::RateLimitPerUserInvalid
when the seconds of the rate limit
per user is more than 21600.
Returns a UpdateChannelError::TopicInvalid
when the length of the topic is more than
1024 UTF-16 characters.
pub fn follow_news_channel(
&self,
channel_id: ChannelId,
webhook_channel_id: ChannelId
) -> FollowNewsChannel<'_>ⓘNotable traits for FollowNewsChannel<'_>
impl Future for FollowNewsChannel<'_> type Output = Result<FollowedChannel>;
[src]
pub fn follow_news_channel(
&self,
channel_id: ChannelId,
webhook_channel_id: ChannelId
) -> FollowNewsChannel<'_>ⓘNotable traits for FollowNewsChannel<'_>
impl Future for FollowNewsChannel<'_> type Output = Result<FollowedChannel>;
[src]Follows a news channel by ChannelId
.
The type returned is FollowedChannel
.
pub fn channel_invites(&self, channel_id: ChannelId) -> GetChannelInvites<'_>ⓘNotable traits for GetChannelInvites<'_>
impl Future for GetChannelInvites<'_> type Output = Result<Vec<Invite>>;
[src]
pub fn channel_invites(&self, channel_id: ChannelId) -> GetChannelInvites<'_>ⓘNotable traits for GetChannelInvites<'_>
impl Future for GetChannelInvites<'_> type Output = Result<Vec<Invite>>;
[src]Get the invites for a guild channel.
This method only works if the channel is of type GuildChannel
.
pub fn channel_messages(&self, channel_id: ChannelId) -> GetChannelMessages<'_>ⓘNotable traits for GetChannelMessages<'_>
impl Future for GetChannelMessages<'_> type Output = Result<Vec<Message>>;
[src]
pub fn channel_messages(&self, channel_id: ChannelId) -> GetChannelMessages<'_>ⓘNotable traits for GetChannelMessages<'_>
impl Future for GetChannelMessages<'_> type Output = Result<Vec<Message>>;
[src]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"); let channel_id = ChannelId(123); let message_id = MessageId(234); let limit: u64 = 6; let messages = client .channel_messages(channel_id) .before(message_id) .limit(limit)? .await?;
Errors
Returns GetChannelMessagesError::LimitInvalid
if the amount is less than 1 or greater than 100.
pub fn delete_channel_permission(
&self,
channel_id: ChannelId
) -> DeleteChannelPermission<'_>
[src]
&self,
channel_id: ChannelId
) -> DeleteChannelPermission<'_>
pub fn update_channel_permission(
&self,
channel_id: ChannelId,
allow: Permissions,
deny: Permissions
) -> UpdateChannelPermission<'_>
[src]
pub fn update_channel_permission(
&self,
channel_id: ChannelId,
allow: Permissions,
deny: Permissions
) -> UpdateChannelPermission<'_>
[src]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(123); let allow = Permissions::VIEW_CHANNEL; let deny = Permissions::SEND_MESSAGES; let role_id = RoleId(432); client.update_channel_permission(channel_id, allow, deny) .role(role_id) .await?;
pub fn channel_webhooks(&self, channel_id: ChannelId) -> GetChannelWebhooks<'_>ⓘNotable traits for GetChannelWebhooks<'_>
impl Future for GetChannelWebhooks<'_> type Output = Result<Vec<Webhook>>;
[src]
pub fn channel_webhooks(&self, channel_id: ChannelId) -> GetChannelWebhooks<'_>ⓘNotable traits for GetChannelWebhooks<'_>
impl Future for GetChannelWebhooks<'_> type Output = Result<Vec<Webhook>>;
[src]Get all the webhooks of a channel.
pub fn current_user(&self) -> GetCurrentUser<'_>ⓘNotable traits for GetCurrentUser<'_>
impl Future for GetCurrentUser<'_> type Output = Result<CurrentUser>;
[src]
pub fn current_user(&self) -> GetCurrentUser<'_>ⓘNotable traits for GetCurrentUser<'_>
impl Future for GetCurrentUser<'_> type Output = Result<CurrentUser>;
[src]Get information about the current user.
pub fn current_user_application(&self) -> GetUserApplicationInfo<'_>ⓘNotable traits for GetUserApplicationInfo<'_>
impl Future for GetUserApplicationInfo<'_> type Output = Result<CurrentApplicationInfo>;
[src]
pub fn current_user_application(&self) -> GetUserApplicationInfo<'_>ⓘNotable traits for GetUserApplicationInfo<'_>
impl Future for GetUserApplicationInfo<'_> type Output = Result<CurrentApplicationInfo>;
[src]Get information about the current bot application.
pub fn update_current_user(&self) -> UpdateCurrentUser<'_>ⓘNotable traits for UpdateCurrentUser<'_>
impl Future for UpdateCurrentUser<'_> type Output = Result<User>;
[src]
pub fn update_current_user(&self) -> UpdateCurrentUser<'_>ⓘNotable traits for UpdateCurrentUser<'_>
impl Future for UpdateCurrentUser<'_> type Output = Result<User>;
[src]Update the current user.
All paramaters are optional. If the username is changed, it may cause the discriminator to be randomized.
pub fn current_user_connections(&self) -> GetCurrentUserConnections<'_>ⓘNotable traits for GetCurrentUserConnections<'_>
impl Future for GetCurrentUserConnections<'_> type Output = Result<Vec<Connection>>;
[src]
pub fn current_user_connections(&self) -> GetCurrentUserConnections<'_>ⓘNotable traits for GetCurrentUserConnections<'_>
impl Future for GetCurrentUserConnections<'_> type Output = Result<Vec<Connection>>;
[src]Get the current user’s connections.
Requires the connections
OAuth2
scope.
pub fn current_user_guilds(&self) -> GetCurrentUserGuilds<'_>ⓘNotable traits for GetCurrentUserGuilds<'_>
impl Future for GetCurrentUserGuilds<'_> type Output = Result<Vec<CurrentUserGuild>>;
[src]
pub fn current_user_guilds(&self) -> GetCurrentUserGuilds<'_>ⓘNotable traits for GetCurrentUserGuilds<'_>
impl Future for GetCurrentUserGuilds<'_> type Output = Result<Vec<CurrentUserGuild>>;
[src]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(300); let before = GuildId(400); let guilds = client.current_user_guilds() .after(after) .before(before) .limit(25)? .await?;
Errors
Returns GetCurrentUserGuildsError::LimitInvalid
if the amount is greater
than 100.
pub fn update_current_user_nick(
&self,
guild_id: GuildId,
nick: impl Into<String>
) -> UpdateCurrentUserNick<'_>ⓘNotable traits for UpdateCurrentUserNick<'_>
impl Future for UpdateCurrentUserNick<'_> type Output = Result<()>;
[src]
pub fn update_current_user_nick(
&self,
guild_id: GuildId,
nick: impl Into<String>
) -> UpdateCurrentUserNick<'_>ⓘNotable traits for UpdateCurrentUserNick<'_>
impl Future for UpdateCurrentUserNick<'_> type Output = Result<()>;
[src]Changes the user’s nickname in a guild.
pub fn current_user_private_channels(&self) -> GetCurrentUserPrivateChannels<'_>ⓘNotable traits for GetCurrentUserPrivateChannels<'_>
impl Future for GetCurrentUserPrivateChannels<'_> type Output = Result<Vec<PrivateChannel>>;
[src]
pub fn current_user_private_channels(&self) -> GetCurrentUserPrivateChannels<'_>ⓘNotable traits for GetCurrentUserPrivateChannels<'_>
impl Future for GetCurrentUserPrivateChannels<'_> type Output = Result<Vec<PrivateChannel>>;
[src]Get a list of the current user’s private channels.
pub fn emojis(&self, guild_id: GuildId) -> GetEmojis<'_>ⓘ
[src]
pub fn emojis(&self, guild_id: GuildId) -> GetEmojis<'_>ⓘ
[src]Get the emojis for a guild, by the guild’s id.
Examples
Get the emojis for guild 100
:
let guild_id = GuildId(100); client.emojis(guild_id).await?;
pub fn emoji(&self, guild_id: GuildId, emoji_id: EmojiId) -> GetEmoji<'_>ⓘ
[src]
pub fn emoji(&self, guild_id: GuildId, emoji_id: EmojiId) -> GetEmoji<'_>ⓘ
[src]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(50); let emoji_id = EmojiId(100); client.emoji(guild_id, emoji_id).await?;
pub fn create_emoji(
&self,
guild_id: GuildId,
name: impl Into<String>,
image: impl Into<String>
) -> CreateEmoji<'_>ⓘNotable traits for CreateEmoji<'_>
impl Future for CreateEmoji<'_> type Output = Result<Emoji>;
[src]
pub fn create_emoji(
&self,
guild_id: GuildId,
name: impl Into<String>,
image: impl Into<String>
) -> CreateEmoji<'_>ⓘNotable traits for CreateEmoji<'_>
impl Future for CreateEmoji<'_> type Output = Result<Emoji>;
[src]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.
pub fn delete_emoji(
&self,
guild_id: GuildId,
emoji_id: EmojiId
) -> DeleteEmoji<'_>ⓘNotable traits for DeleteEmoji<'_>
impl Future for DeleteEmoji<'_> type Output = Result<()>;
[src]
pub fn delete_emoji(
&self,
guild_id: GuildId,
emoji_id: EmojiId
) -> DeleteEmoji<'_>ⓘNotable traits for DeleteEmoji<'_>
impl Future for DeleteEmoji<'_> type Output = Result<()>;
[src]Delete an emoji in a guild, by id.
pub fn update_emoji(
&self,
guild_id: GuildId,
emoji_id: EmojiId
) -> UpdateEmoji<'_>ⓘNotable traits for UpdateEmoji<'_>
impl Future for UpdateEmoji<'_> type Output = Result<Emoji>;
[src]
pub fn update_emoji(
&self,
guild_id: GuildId,
emoji_id: EmojiId
) -> UpdateEmoji<'_>ⓘNotable traits for UpdateEmoji<'_>
impl Future for UpdateEmoji<'_> type Output = Result<Emoji>;
[src]Update an emoji in a guild, by id.
pub fn gateway(&self) -> GetGateway<'_>ⓘNotable traits for GetGateway<'_>
impl Future for GetGateway<'_> type Output = Result<ConnectionInfo>;
[src]
pub fn gateway(&self) -> GetGateway<'_>ⓘNotable traits for GetGateway<'_>
impl Future for GetGateway<'_> type Output = Result<ConnectionInfo>;
[src]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().await?;
Get the gateway connection URL with additional shard and session information, which requires specifying a bot token:
let info = client.gateway().authed().await?; println!("URL: {}", info.url); println!("Recommended shards to use: {}", info.shards);
pub fn create_guild(
&self,
name: impl Into<String>
) -> StdResult<CreateGuild<'_>, CreateGuildError>
[src]
pub fn create_guild(
&self,
name: impl Into<String>
) -> StdResult<CreateGuild<'_>, CreateGuildError>
[src]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 CreateGuildError::NameInvalid
if the name length is too short or too long.
pub fn delete_guild(&self, guild_id: GuildId) -> DeleteGuild<'_>ⓘNotable traits for DeleteGuild<'_>
impl Future for DeleteGuild<'_> type Output = Result<()>;
[src]
pub fn delete_guild(&self, guild_id: GuildId) -> DeleteGuild<'_>ⓘNotable traits for DeleteGuild<'_>
impl Future for DeleteGuild<'_> type Output = Result<()>;
[src]Delete a guild permanently. The user must be the owner.
pub fn update_guild(&self, guild_id: GuildId) -> UpdateGuild<'_>ⓘNotable traits for UpdateGuild<'_>
impl Future for UpdateGuild<'_> type Output = Result<PartialGuild>;
[src]
pub fn update_guild(&self, guild_id: GuildId) -> UpdateGuild<'_>ⓘNotable traits for UpdateGuild<'_>
impl Future for UpdateGuild<'_> type Output = Result<PartialGuild>;
[src]Update a guild.
All endpoints are optional. Refer to the discord docs for more information.
pub fn leave_guild(&self, guild_id: GuildId) -> LeaveGuild<'_>ⓘNotable traits for LeaveGuild<'_>
impl Future for LeaveGuild<'_> type Output = Result<()>;
[src]
pub fn leave_guild(&self, guild_id: GuildId) -> LeaveGuild<'_>ⓘNotable traits for LeaveGuild<'_>
impl Future for LeaveGuild<'_> type Output = Result<()>;
[src]Leave a guild by id.
pub fn guild_channels(&self, guild_id: GuildId) -> GetGuildChannels<'_>ⓘNotable traits for GetGuildChannels<'_>
impl Future for GetGuildChannels<'_> type Output = Result<Vec<GuildChannel>>;
[src]
pub fn guild_channels(&self, guild_id: GuildId) -> GetGuildChannels<'_>ⓘNotable traits for GetGuildChannels<'_>
impl Future for GetGuildChannels<'_> type Output = Result<Vec<GuildChannel>>;
[src]Get the channels in a guild.
pub fn create_guild_channel(
&self,
guild_id: GuildId,
name: impl Into<String>
) -> StdResult<CreateGuildChannel<'_>, CreateGuildChannelError>
[src]
pub fn create_guild_channel(
&self,
guild_id: GuildId,
name: impl Into<String>
) -> StdResult<CreateGuildChannel<'_>, CreateGuildChannelError>
[src]Create a new request to create a guild channel.
All fields are optional except for name. The minimum length of the name is 2 UTF-16 characters and the maximum is 100 UTF-16 characters.
Errors
Returns a CreateGuildChannelError::NameInvalid
when the length of the name is either
fewer than 2 UTF-16 characters or more than 100 UTF-16 characters.
Returns a CreateGuildChannelError::RateLimitPerUserInvalid
when the seconds of the rate
limit per user is more than 21600.
Returns a CreateGuildChannelError::TopicInvalid
when the length of the topic is more
than
1024 UTF-16 characters.
pub fn update_guild_channel_positions(
&self,
guild_id: GuildId,
channel_positions: impl Iterator<Item = (ChannelId, u64)>
) -> UpdateGuildChannelPositions<'_>ⓘNotable traits for UpdateGuildChannelPositions<'_>
impl Future for UpdateGuildChannelPositions<'_> type Output = Result<()>;
[src]
pub fn update_guild_channel_positions(
&self,
guild_id: GuildId,
channel_positions: impl Iterator<Item = (ChannelId, u64)>
) -> UpdateGuildChannelPositions<'_>ⓘNotable traits for UpdateGuildChannelPositions<'_>
impl Future for UpdateGuildChannelPositions<'_> type Output = Result<()>;
[src]Modify the positions of the channels.
The minimum amount of channels to modify, is a swap between two channels.
pub fn guild_widget(&self, guild_id: GuildId) -> GetGuildWidget<'_>ⓘNotable traits for GetGuildWidget<'_>
impl Future for GetGuildWidget<'_> type Output = Result<Option<GuildWidget>>;
[src]
pub fn guild_widget(&self, guild_id: GuildId) -> GetGuildWidget<'_>ⓘNotable traits for GetGuildWidget<'_>
impl Future for GetGuildWidget<'_> type Output = Result<Option<GuildWidget>>;
[src]Get the guild widget.
Refer to the discord docs for more information.
pub fn update_guild_widget(&self, guild_id: GuildId) -> UpdateGuildWidget<'_>ⓘNotable traits for UpdateGuildWidget<'_>
impl Future for UpdateGuildWidget<'_> type Output = Result<GuildWidget>;
[src]
pub fn update_guild_widget(&self, guild_id: GuildId) -> UpdateGuildWidget<'_>ⓘNotable traits for UpdateGuildWidget<'_>
impl Future for UpdateGuildWidget<'_> type Output = Result<GuildWidget>;
[src]Modify the guild widget.
pub fn guild_integrations(&self, guild_id: GuildId) -> GetGuildIntegrations<'_>ⓘNotable traits for GetGuildIntegrations<'_>
impl Future for GetGuildIntegrations<'_> type Output = Result<Vec<GuildIntegration>>;
[src]
pub fn guild_integrations(&self, guild_id: GuildId) -> GetGuildIntegrations<'_>ⓘNotable traits for GetGuildIntegrations<'_>
impl Future for GetGuildIntegrations<'_> type Output = Result<Vec<GuildIntegration>>;
[src]Get the guild’s integrations.
pub fn create_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId,
kind: impl Into<String>
) -> CreateGuildIntegration<'_>ⓘNotable traits for CreateGuildIntegration<'_>
impl Future for CreateGuildIntegration<'_> type Output = Result<()>;
[src]
pub fn create_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId,
kind: impl Into<String>
) -> CreateGuildIntegration<'_>ⓘNotable traits for CreateGuildIntegration<'_>
impl Future for CreateGuildIntegration<'_> type Output = Result<()>;
[src]Create a guild integration from the current user to the guild.
Refer to the discord docs for more information.
pub fn delete_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> DeleteGuildIntegration<'_>ⓘNotable traits for DeleteGuildIntegration<'_>
impl Future for DeleteGuildIntegration<'_> type Output = Result<()>;
[src]
pub fn delete_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> DeleteGuildIntegration<'_>ⓘNotable traits for DeleteGuildIntegration<'_>
impl Future for DeleteGuildIntegration<'_> type Output = Result<()>;
[src]Delete an integration for a guild, by the integration’s id.
pub fn update_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> UpdateGuildIntegration<'_>ⓘNotable traits for UpdateGuildIntegration<'_>
impl Future for UpdateGuildIntegration<'_> type Output = Result<()>;
[src]
pub fn update_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> UpdateGuildIntegration<'_>ⓘNotable traits for UpdateGuildIntegration<'_>
impl Future for UpdateGuildIntegration<'_> type Output = Result<()>;
[src]Update a guild’s integration, by its id.
Refer to the discord docs for more information.
pub fn sync_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> SyncGuildIntegration<'_>ⓘNotable traits for SyncGuildIntegration<'_>
impl Future for SyncGuildIntegration<'_> type Output = Result<()>;
[src]
pub fn sync_guild_integration(
&self,
guild_id: GuildId,
integration_id: IntegrationId
) -> SyncGuildIntegration<'_>ⓘNotable traits for SyncGuildIntegration<'_>
impl Future for SyncGuildIntegration<'_> type Output = Result<()>;
[src]Synchronize a guild’s integration by its id.
pub fn guild_invites(&self, guild_id: GuildId) -> GetGuildInvites<'_>ⓘNotable traits for GetGuildInvites<'_>
impl Future for GetGuildInvites<'_> type Output = Result<Vec<Invite>>;
[src]
pub fn guild_invites(&self, guild_id: GuildId) -> GetGuildInvites<'_>ⓘNotable traits for GetGuildInvites<'_>
impl Future for GetGuildInvites<'_> type Output = Result<Vec<Invite>>;
[src]Get information about the invites of a guild.
pub fn guild_members(&self, guild_id: GuildId) -> GetGuildMembers<'_>ⓘNotable traits for GetGuildMembers<'_>
impl Future for GetGuildMembers<'_> type Output = Result<Vec<Member>>;
[src]
pub fn guild_members(&self, guild_id: GuildId) -> GetGuildMembers<'_>ⓘNotable traits for GetGuildMembers<'_>
impl Future for GetGuildMembers<'_> type Output = Result<Vec<Member>>;
[src]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(100); let user_id = UserId(3000); let members = client.guild_members(guild_id).after(user_id).await?;
Errors
Returns GetGuildMembersError::LimitInvalid
if the limit is invalid.
pub fn search_guild_members(
&self,
guild_id: GuildId,
query: impl Into<String>
) -> SearchGuildMembers<'_>ⓘNotable traits for SearchGuildMembers<'_>
impl Future for SearchGuildMembers<'_> type Output = Result<Vec<Member>>;
[src]
pub fn search_guild_members(
&self,
guild_id: GuildId,
query: impl Into<String>
) -> SearchGuildMembers<'_>ⓘNotable traits for SearchGuildMembers<'_>
impl Future for SearchGuildMembers<'_> type Output = Result<Vec<Member>>;
[src]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"); let guild_id = GuildId(100); let members = client.search_guild_members(guild_id, String::from("Wumpus")).limit(10)?.await?;
Errors
Returns SearchGuildMembersError::LimitInvalid
if the limit is invalid.
pub fn guild_member(&self, guild_id: GuildId, user_id: UserId) -> GetMember<'_>ⓘ
[src]
pub fn guild_member(&self, guild_id: GuildId, user_id: UserId) -> GetMember<'_>ⓘ
[src]Get a member of a guild, by their id.
pub fn add_guild_member(
&self,
guild_id: GuildId,
user_id: UserId,
access_token: impl Into<String>
) -> AddGuildMember<'_>ⓘNotable traits for AddGuildMember<'_>
impl Future for AddGuildMember<'_> type Output = Result<Option<PartialMember>>;
[src]
pub fn add_guild_member(
&self,
guild_id: GuildId,
user_id: UserId,
access_token: impl Into<String>
) -> AddGuildMember<'_>ⓘNotable traits for AddGuildMember<'_>
impl Future for AddGuildMember<'_> type Output = Result<Option<PartialMember>>;
[src]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 AddGuildMemberError::NicknameInvalid
if the nickname is too
short or too long.
pub fn remove_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> RemoveMember<'_>ⓘNotable traits for RemoveMember<'_>
impl Future for RemoveMember<'_> type Output = Result<()>;
[src]
pub fn remove_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> RemoveMember<'_>ⓘNotable traits for RemoveMember<'_>
impl Future for RemoveMember<'_> type Output = Result<()>;
[src]Kick a member from a guild.
pub fn update_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> UpdateGuildMember<'_>ⓘNotable traits for UpdateGuildMember<'_>
impl Future for UpdateGuildMember<'_> type Output = Result<()>;
[src]
pub fn update_guild_member(
&self,
guild_id: GuildId,
user_id: UserId
) -> UpdateGuildMember<'_>ⓘNotable traits for UpdateGuildMember<'_>
impl Future for UpdateGuildMember<'_> type Output = Result<()>;
[src]Update a guild member.
All fields are optional. Refer to the discord docs for more information.
Errors
Returns UpdateGuildMemberError::NicknameInvalid
if the nickname length is too short or too
long.
pub fn add_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> AddRoleToMember<'_>ⓘNotable traits for AddRoleToMember<'_>
impl Future for AddRoleToMember<'_> type Output = Result<()>;
[src]
pub fn add_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> AddRoleToMember<'_>ⓘNotable traits for AddRoleToMember<'_>
impl Future for AddRoleToMember<'_> type Output = Result<()>;
[src]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(1); let role_id = RoleId(2); let user_id = UserId(3); client.add_guild_member_role(guild_id, user_id, role_id).reason("test")?.await?;
pub fn remove_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> RemoveRoleFromMember<'_>ⓘNotable traits for RemoveRoleFromMember<'_>
impl Future for RemoveRoleFromMember<'_> type Output = Result<()>;
[src]
pub fn remove_guild_member_role(
&self,
guild_id: GuildId,
user_id: UserId,
role_id: RoleId
) -> RemoveRoleFromMember<'_>ⓘNotable traits for RemoveRoleFromMember<'_>
impl Future for RemoveRoleFromMember<'_> type Output = Result<()>;
[src]Remove a role from a member in a guild, by id.
pub fn guild_preview(&self, guild_id: GuildId) -> GetGuildPreview<'_>ⓘNotable traits for GetGuildPreview<'_>
impl Future for GetGuildPreview<'_> type Output = Result<GuildPreview>;
[src]
pub fn guild_preview(&self, guild_id: GuildId) -> GetGuildPreview<'_>ⓘNotable traits for GetGuildPreview<'_>
impl Future for GetGuildPreview<'_> type Output = Result<GuildPreview>;
[src]For public guilds, get the guild preview.
This works even if the user is not in the guild.
pub fn guild_prune_count(&self, guild_id: GuildId) -> GetGuildPruneCount<'_>ⓘNotable traits for GetGuildPruneCount<'_>
impl Future for GetGuildPruneCount<'_> type Output = Result<GuildPrune>;
[src]
pub fn guild_prune_count(&self, guild_id: GuildId) -> GetGuildPruneCount<'_>ⓘNotable traits for GetGuildPruneCount<'_>
impl Future for GetGuildPruneCount<'_> type Output = Result<GuildPrune>;
[src]Get the counts of guild members to be pruned.
pub fn create_guild_prune(&self, guild_id: GuildId) -> CreateGuildPrune<'_>ⓘNotable traits for CreateGuildPrune<'_>
impl Future for CreateGuildPrune<'_> type Output = Result<Option<GuildPrune>>;
[src]
pub fn create_guild_prune(&self, guild_id: GuildId) -> CreateGuildPrune<'_>ⓘNotable traits for CreateGuildPrune<'_>
impl Future for CreateGuildPrune<'_> type Output = Result<Option<GuildPrune>>;
[src]Begin a guild prune.
Refer to the discord docs for more information.
pub fn guild_vanity_url(&self, guild_id: GuildId) -> GetGuildVanityUrl<'_>ⓘNotable traits for GetGuildVanityUrl<'_>
impl Future for GetGuildVanityUrl<'_> type Output = Result<Option<String>>;
[src]
pub fn guild_vanity_url(&self, guild_id: GuildId) -> GetGuildVanityUrl<'_>ⓘNotable traits for GetGuildVanityUrl<'_>
impl Future for GetGuildVanityUrl<'_> type Output = Result<Option<String>>;
[src]Get a guild’s vanity url, if there is one.
pub fn guild_voice_regions(&self, guild_id: GuildId) -> GetGuildVoiceRegions<'_>ⓘNotable traits for GetGuildVoiceRegions<'_>
impl Future for GetGuildVoiceRegions<'_> type Output = Result<Vec<VoiceRegion>>;
[src]
pub fn guild_voice_regions(&self, guild_id: GuildId) -> GetGuildVoiceRegions<'_>ⓘNotable traits for GetGuildVoiceRegions<'_>
impl Future for GetGuildVoiceRegions<'_> type Output = Result<Vec<VoiceRegion>>;
[src]Get voice region data for the guild.
Can return VIP servers if the guild is VIP-enabled.
pub fn guild_webhooks(&self, guild_id: GuildId) -> GetGuildWebhooks<'_>ⓘNotable traits for GetGuildWebhooks<'_>
impl Future for GetGuildWebhooks<'_> type Output = Result<Vec<Webhook>>;
[src]
pub fn guild_webhooks(&self, guild_id: GuildId) -> GetGuildWebhooks<'_>ⓘNotable traits for GetGuildWebhooks<'_>
impl Future for GetGuildWebhooks<'_> type Output = Result<Vec<Webhook>>;
[src]Get the webhooks of a guild.
pub fn guild_welcome_screen(
&self,
guild_id: GuildId
) -> GetGuildWelcomeScreen<'_>ⓘNotable traits for GetGuildWelcomeScreen<'_>
impl Future for GetGuildWelcomeScreen<'_> type Output = Result<Option<WelcomeScreen>>;
[src]
pub fn guild_welcome_screen(
&self,
guild_id: GuildId
) -> GetGuildWelcomeScreen<'_>ⓘNotable traits for GetGuildWelcomeScreen<'_>
impl Future for GetGuildWelcomeScreen<'_> type Output = Result<Option<WelcomeScreen>>;
[src]Get the guild’s welcome screen.
pub fn update_guild_welcome_screen(
&self,
guild_id: GuildId
) -> UpdateGuildWelcomeScreen<'_>ⓘNotable traits for UpdateGuildWelcomeScreen<'_>
impl Future for UpdateGuildWelcomeScreen<'_> type Output = Result<WelcomeScreen>;
[src]
pub fn update_guild_welcome_screen(
&self,
guild_id: GuildId
) -> UpdateGuildWelcomeScreen<'_>ⓘNotable traits for UpdateGuildWelcomeScreen<'_>
impl Future for UpdateGuildWelcomeScreen<'_> type Output = Result<WelcomeScreen>;
[src]Update the guild’s welcome screen.
Requires the MANAGE_GUILD
permission.
pub fn invite(&self, code: impl Into<String>) -> GetInvite<'_>ⓘ
[src]
pub fn invite(&self, code: impl Into<String>) -> GetInvite<'_>ⓘ
[src]Get information about an invite by its code.
If with_counts
is called, the returned invite will contain approximate member counts.
Examples
let invite = client .invite("code") .with_counts() .await?;
pub fn create_invite(&self, channel_id: ChannelId) -> CreateInvite<'_>ⓘNotable traits for CreateInvite<'_>
impl Future for CreateInvite<'_> type Output = Result<Invite>;
[src]
pub fn create_invite(&self, channel_id: ChannelId) -> CreateInvite<'_>ⓘNotable traits for CreateInvite<'_>
impl Future for CreateInvite<'_> type Output = Result<Invite>;
[src]Create an invite, with options.
Examples
let channel_id = ChannelId(123); let invite = client .create_invite(channel_id) .max_uses(3) .await?;
pub fn delete_invite(&self, code: impl Into<String>) -> DeleteInvite<'_>ⓘNotable traits for DeleteInvite<'_>
impl Future for DeleteInvite<'_> type Output = Result<()>;
[src]
pub fn delete_invite(&self, code: impl Into<String>) -> DeleteInvite<'_>ⓘNotable traits for DeleteInvite<'_>
impl Future for DeleteInvite<'_> type Output = Result<()>;
[src]Delete an invite by its code.
pub fn message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> GetMessage<'_>ⓘNotable traits for GetMessage<'_>
impl Future for GetMessage<'_> type Output = Result<Option<Message>>;
[src]
pub fn message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> GetMessage<'_>ⓘNotable traits for GetMessage<'_>
impl Future for GetMessage<'_> type Output = Result<Option<Message>>;
[src]pub fn create_message(&self, channel_id: ChannelId) -> CreateMessage<'_>ⓘNotable traits for CreateMessage<'_>
impl Future for CreateMessage<'_> type Output = Result<Message>;
[src]
pub fn create_message(&self, channel_id: ChannelId) -> CreateMessage<'_>ⓘNotable traits for CreateMessage<'_>
impl Future for CreateMessage<'_> type Output = Result<Message>;
[src]Send a message to a channel.
Example
let channel_id = ChannelId(123); let message = client .create_message(channel_id) .content("Twilight is best pony")? .tts(true) .await?;
Errors
The method content
returns CreateMessageError::ContentInvalid
if the content is
over 2000 UTF-16 characters.
The method embed
returns CreateMessageError::EmbedTooLarge
if the length of the
embed is over 6000 characters.
pub fn delete_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteMessage<'_>ⓘNotable traits for DeleteMessage<'_>
impl Future for DeleteMessage<'_> type Output = Result<()>;
[src]
pub fn delete_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteMessage<'_>ⓘNotable traits for DeleteMessage<'_>
impl Future for DeleteMessage<'_> type Output = Result<()>;
[src]pub fn delete_messages(
&self,
channel_id: ChannelId,
message_ids: impl Into<Vec<MessageId>>
) -> DeleteMessages<'_>ⓘNotable traits for DeleteMessages<'_>
impl Future for DeleteMessages<'_> type Output = Result<()>;
[src]
pub fn delete_messages(
&self,
channel_id: ChannelId,
message_ids: impl Into<Vec<MessageId>>
) -> DeleteMessages<'_>ⓘNotable traits for DeleteMessages<'_>
impl Future for DeleteMessages<'_> type Output = Result<()>;
[src]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 fn update_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> UpdateMessage<'_>ⓘNotable traits for UpdateMessage<'_>
impl Future for UpdateMessage<'_> type Output = Result<Message>;
[src]
pub fn update_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> UpdateMessage<'_>ⓘNotable traits for UpdateMessage<'_>
impl Future for UpdateMessage<'_> type Output = Result<Message>;
[src]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"); client.update_message(ChannelId(1), MessageId(2)) .content("test update".to_owned())? .await?;
Remove the message’s content:
client.update_message(ChannelId(1), MessageId(2)) .content(None)? .await?;
pub fn crosspost_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> CrosspostMessage<'_>ⓘNotable traits for CrosspostMessage<'_>
impl Future for CrosspostMessage<'_> type Output = Result<Message>;
[src]
pub fn crosspost_message(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> CrosspostMessage<'_>ⓘNotable traits for CrosspostMessage<'_>
impl Future for CrosspostMessage<'_> type Output = Result<Message>;
[src]pub fn create_pin(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> CreatePin<'_>ⓘ
[src]
pub fn create_pin(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> CreatePin<'_>ⓘ
[src]Create a new pin in a channel, by ID.
pub fn delete_pin(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeletePin<'_>ⓘ
[src]
pub fn delete_pin(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeletePin<'_>ⓘ
[src]Delete a pin in a channel, by ID.
pub fn reactions(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> GetReactions<'_>ⓘNotable traits for GetReactions<'_>
impl Future for GetReactions<'_> type Output = Result<Vec<User>>;
[src]
pub fn reactions(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> GetReactions<'_>ⓘNotable traits for GetReactions<'_>
impl Future for GetReactions<'_> type Output = Result<Vec<User>>;
[src]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 retireved.
pub fn create_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> CreateReaction<'_>ⓘNotable traits for CreateReaction<'_>
impl Future for CreateReaction<'_> type Output = Result<()>;
[src]
pub fn create_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> CreateReaction<'_>ⓘNotable traits for CreateReaction<'_>
impl Future for CreateReaction<'_> type Output = Result<()>;
[src]Create a reaction in a ChannelId
on a MessageId
.
The reaction must be a variant of RequestReactionType
.
Examples
let channel_id = ChannelId(123); let message_id = MessageId(456); let emoji = RequestReactionType::Unicode { name: String::from("🌃") }; let reaction = client .create_reaction(channel_id, message_id, emoji) .await?;
pub fn delete_current_user_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> DeleteReaction<'_>ⓘNotable traits for DeleteReaction<'_>
impl Future for DeleteReaction<'_> type Output = Result<()>;
[src]
pub fn delete_current_user_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> DeleteReaction<'_>ⓘNotable traits for DeleteReaction<'_>
impl Future for DeleteReaction<'_> type Output = Result<()>;
[src]Delete the current user’s (@me
) reaction on a message.
pub fn delete_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType,
user_id: UserId
) -> DeleteReaction<'_>ⓘNotable traits for DeleteReaction<'_>
impl Future for DeleteReaction<'_> type Output = Result<()>;
[src]
pub fn delete_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType,
user_id: UserId
) -> DeleteReaction<'_>ⓘNotable traits for DeleteReaction<'_>
impl Future for DeleteReaction<'_> type Output = Result<()>;
[src]Delete a reaction by a user on a message.
pub fn delete_all_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> DeleteAllReaction<'_>ⓘNotable traits for DeleteAllReaction<'_>
impl Future for DeleteAllReaction<'_> type Output = Result<()>;
[src]
pub fn delete_all_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
emoji: RequestReactionType
) -> DeleteAllReaction<'_>ⓘNotable traits for DeleteAllReaction<'_>
impl Future for DeleteAllReaction<'_> type Output = Result<()>;
[src]Remove all reactions on a message of an emoji.
pub fn delete_all_reactions(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteAllReactions<'_>ⓘNotable traits for DeleteAllReactions<'_>
impl Future for DeleteAllReactions<'_> type Output = Result<()>;
[src]
pub fn delete_all_reactions(
&self,
channel_id: ChannelId,
message_id: MessageId
) -> DeleteAllReactions<'_>ⓘNotable traits for DeleteAllReactions<'_>
impl Future for DeleteAllReactions<'_> type Output = Result<()>;
[src]Delete all reactions by all users on a message.
pub fn create_typing_trigger(
&self,
channel_id: ChannelId
) -> CreateTypingTrigger<'_>ⓘNotable traits for CreateTypingTrigger<'_>
impl Future for CreateTypingTrigger<'_> type Output = Result<()>;
[src]
pub fn create_typing_trigger(
&self,
channel_id: ChannelId
) -> CreateTypingTrigger<'_>ⓘNotable traits for CreateTypingTrigger<'_>
impl Future for CreateTypingTrigger<'_> type Output = Result<()>;
[src]Fire a Typing Start event in the channel.
pub fn create_private_channel(
&self,
recipient_id: UserId
) -> CreatePrivateChannel<'_>ⓘNotable traits for CreatePrivateChannel<'_>
impl Future for CreatePrivateChannel<'_> type Output = Result<PrivateChannel>;
[src]
pub fn create_private_channel(
&self,
recipient_id: UserId
) -> CreatePrivateChannel<'_>ⓘNotable traits for CreatePrivateChannel<'_>
impl Future for CreatePrivateChannel<'_> type Output = Result<PrivateChannel>;
[src]Create a group DM.
This endpoint is limited to 10 active group DMs.
pub fn roles(&self, guild_id: GuildId) -> GetGuildRoles<'_>ⓘNotable traits for GetGuildRoles<'_>
impl Future for GetGuildRoles<'_> type Output = Result<Vec<Role>>;
[src]
pub fn roles(&self, guild_id: GuildId) -> GetGuildRoles<'_>ⓘNotable traits for GetGuildRoles<'_>
impl Future for GetGuildRoles<'_> type Output = Result<Vec<Role>>;
[src]Get the roles of a guild.
pub fn create_role(&self, guild_id: GuildId) -> CreateRole<'_>ⓘNotable traits for CreateRole<'_>
impl Future for CreateRole<'_> type Output = Result<Role>;
[src]
pub fn create_role(&self, guild_id: GuildId) -> CreateRole<'_>ⓘNotable traits for CreateRole<'_>
impl Future for CreateRole<'_> type Output = Result<Role>;
[src]Create a role in a guild.
Examples
use twilight_model::id::GuildId; let guild_id = GuildId(234); client.create_role(guild_id) .color(0xd90083) .name("Bright Pink") .await?;
pub fn delete_role(&self, guild_id: GuildId, role_id: RoleId) -> DeleteRole<'_>ⓘNotable traits for DeleteRole<'_>
impl Future for DeleteRole<'_> type Output = Result<()>;
[src]
pub fn delete_role(&self, guild_id: GuildId, role_id: RoleId) -> DeleteRole<'_>ⓘNotable traits for DeleteRole<'_>
impl Future for DeleteRole<'_> type Output = Result<()>;
[src]Delete a role in a guild, by id.
pub fn update_role(&self, guild_id: GuildId, role_id: RoleId) -> UpdateRole<'_>ⓘNotable traits for UpdateRole<'_>
impl Future for UpdateRole<'_> type Output = Result<Role>;
[src]
pub fn update_role(&self, guild_id: GuildId, role_id: RoleId) -> UpdateRole<'_>ⓘNotable traits for UpdateRole<'_>
impl Future for UpdateRole<'_> type Output = Result<Role>;
[src]Update a role by guild id and its id.
pub fn update_role_positions(
&self,
guild_id: GuildId,
roles: impl Iterator<Item = (RoleId, u64)>
) -> UpdateRolePositions<'_>ⓘNotable traits for UpdateRolePositions<'_>
impl Future for UpdateRolePositions<'_> type Output = Result<Vec<Role>>;
[src]
pub fn update_role_positions(
&self,
guild_id: GuildId,
roles: impl Iterator<Item = (RoleId, u64)>
) -> UpdateRolePositions<'_>ⓘNotable traits for UpdateRolePositions<'_>
impl Future for UpdateRolePositions<'_> type Output = Result<Vec<Role>>;
[src]Modify the position of the roles.
The minimum amount of roles to modify, is a swap between two roles.
pub fn create_guild_from_template(
&self,
template_code: impl Into<String>,
name: impl Into<String>
) -> StdResult<CreateGuildFromTemplate<'_>, CreateGuildFromTemplateError>
[src]
pub fn create_guild_from_template(
&self,
template_code: impl Into<String>,
name: impl Into<String>
) -> StdResult<CreateGuildFromTemplate<'_>, CreateGuildFromTemplateError>
[src]Create a new guild based on a template.
This endpoint can only be used by bots in less than 10 guilds.
Errors
Returns CreateGuildFromTemplateError::NameInvalid
when the name is
invalid.
pub fn create_template(
&self,
guild_id: GuildId,
name: impl Into<String>
) -> StdResult<CreateTemplate<'_>, CreateTemplateError>
[src]
pub fn create_template(
&self,
guild_id: GuildId,
name: impl Into<String>
) -> StdResult<CreateTemplate<'_>, CreateTemplateError>
[src]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 CreateTemplateError::NameInvalid
when the name is invalid.
pub fn delete_template(
&self,
guild_id: GuildId,
template_code: impl Into<String>
) -> DeleteTemplate<'_>ⓘNotable traits for DeleteTemplate<'_>
impl Future for DeleteTemplate<'_> type Output = Result<()>;
[src]
pub fn delete_template(
&self,
guild_id: GuildId,
template_code: impl Into<String>
) -> DeleteTemplate<'_>ⓘNotable traits for DeleteTemplate<'_>
impl Future for DeleteTemplate<'_> type Output = Result<()>;
[src]Delete a template by ID and code.
pub fn get_template(&self, template_code: impl Into<String>) -> GetTemplate<'_>ⓘNotable traits for GetTemplate<'_>
impl Future for GetTemplate<'_> type Output = Result<Template>;
[src]
pub fn get_template(&self, template_code: impl Into<String>) -> GetTemplate<'_>ⓘNotable traits for GetTemplate<'_>
impl Future for GetTemplate<'_> type Output = Result<Template>;
[src]Get a template by its code.
pub fn get_templates(&self, guild_id: GuildId) -> GetTemplates<'_>ⓘNotable traits for GetTemplates<'_>
impl Future for GetTemplates<'_> type Output = Result<Vec<Template>>;
[src]
pub fn get_templates(&self, guild_id: GuildId) -> GetTemplates<'_>ⓘNotable traits for GetTemplates<'_>
impl Future for GetTemplates<'_> type Output = Result<Vec<Template>>;
[src]Get a list of templates in a guild, by ID.
pub fn sync_template(
&self,
guild_id: GuildId,
template_code: impl Into<String>
) -> SyncTemplate<'_>ⓘNotable traits for SyncTemplate<'_>
impl Future for SyncTemplate<'_> type Output = Result<Template>;
[src]
pub fn sync_template(
&self,
guild_id: GuildId,
template_code: impl Into<String>
) -> SyncTemplate<'_>ⓘNotable traits for SyncTemplate<'_>
impl Future for SyncTemplate<'_> type Output = Result<Template>;
[src]Sync a template to the current state of the guild, by ID and code.
pub fn update_template(
&self,
guild_id: GuildId,
template_code: impl Into<String>
) -> UpdateTemplate<'_>ⓘNotable traits for UpdateTemplate<'_>
impl Future for UpdateTemplate<'_> type Output = Result<Template>;
[src]
pub fn update_template(
&self,
guild_id: GuildId,
template_code: impl Into<String>
) -> UpdateTemplate<'_>ⓘNotable traits for UpdateTemplate<'_>
impl Future for UpdateTemplate<'_> type Output = Result<Template>;
[src]Update the template’s metadata, by ID and code.
pub fn voice_regions(&self) -> GetVoiceRegions<'_>ⓘNotable traits for GetVoiceRegions<'_>
impl Future for GetVoiceRegions<'_> type Output = Result<Vec<VoiceRegion>>;
[src]
pub fn voice_regions(&self) -> GetVoiceRegions<'_>ⓘNotable traits for GetVoiceRegions<'_>
impl Future for GetVoiceRegions<'_> type Output = Result<Vec<VoiceRegion>>;
[src]Get a list of voice regions that can be used when creating a guild.
pub fn webhook(&self, id: WebhookId) -> GetWebhook<'_>ⓘNotable traits for GetWebhook<'_>
impl Future for GetWebhook<'_> type Output = Result<Option<Webhook>>;
[src]
pub fn webhook(&self, id: WebhookId) -> GetWebhook<'_>ⓘNotable traits for GetWebhook<'_>
impl Future for GetWebhook<'_> type Output = Result<Option<Webhook>>;
[src]Get a webhook by ID.
pub fn create_webhook(
&self,
channel_id: ChannelId,
name: impl Into<String>
) -> CreateWebhook<'_>ⓘNotable traits for CreateWebhook<'_>
impl Future for CreateWebhook<'_> type Output = Result<Webhook>;
[src]
pub fn create_webhook(
&self,
channel_id: ChannelId,
name: impl Into<String>
) -> CreateWebhook<'_>ⓘNotable traits for CreateWebhook<'_>
impl Future for CreateWebhook<'_> type Output = Result<Webhook>;
[src]Create a webhook in a channel.
Examples
let channel_id = ChannelId(123); let webhook = client .create_webhook(channel_id, "Twily Bot") .await?;
pub fn delete_webhook(&self, id: WebhookId) -> DeleteWebhook<'_>ⓘNotable traits for DeleteWebhook<'_>
impl Future for DeleteWebhook<'_> type Output = Result<()>;
[src]
pub fn delete_webhook(&self, id: WebhookId) -> DeleteWebhook<'_>ⓘNotable traits for DeleteWebhook<'_>
impl Future for DeleteWebhook<'_> type Output = Result<()>;
[src]Delete a webhook by its ID.
pub fn update_webhook(&self, webhook_id: WebhookId) -> UpdateWebhook<'_>ⓘNotable traits for UpdateWebhook<'_>
impl Future for UpdateWebhook<'_> type Output = Result<Webhook>;
[src]
pub fn update_webhook(&self, webhook_id: WebhookId) -> UpdateWebhook<'_>ⓘNotable traits for UpdateWebhook<'_>
impl Future for UpdateWebhook<'_> type Output = Result<Webhook>;
[src]Update a webhook by ID.
pub fn update_webhook_with_token(
&self,
webhook_id: WebhookId,
token: impl Into<String>
) -> UpdateWebhookWithToken<'_>ⓘNotable traits for UpdateWebhookWithToken<'_>
impl Future for UpdateWebhookWithToken<'_> type Output = Result<Webhook>;
[src]
pub fn update_webhook_with_token(
&self,
webhook_id: WebhookId,
token: impl Into<String>
) -> UpdateWebhookWithToken<'_>ⓘNotable traits for UpdateWebhookWithToken<'_>
impl Future for UpdateWebhookWithToken<'_> type Output = Result<Webhook>;
[src]Update a webhook, with a token, by ID.
pub fn execute_webhook(
&self,
webhook_id: WebhookId,
token: impl Into<String>
) -> ExecuteWebhook<'_>ⓘNotable traits for ExecuteWebhook<'_>
impl Future for ExecuteWebhook<'_> type Output = Result<Option<Message>>;
[src]
pub fn execute_webhook(
&self,
webhook_id: WebhookId,
token: impl Into<String>
) -> ExecuteWebhook<'_>ⓘNotable traits for ExecuteWebhook<'_>
impl Future for ExecuteWebhook<'_> type Output = Result<Option<Message>>;
[src]pub fn update_webhook_message(
&self,
webhook_id: WebhookId,
token: impl Into<String>,
message_id: MessageId
) -> UpdateWebhookMessage<'_>ⓘNotable traits for UpdateWebhookMessage<'_>
impl Future for UpdateWebhookMessage<'_> type Output = Result<()>;
[src]
pub fn update_webhook_message(
&self,
webhook_id: WebhookId,
token: impl Into<String>,
message_id: MessageId
) -> UpdateWebhookMessage<'_>ⓘNotable traits for UpdateWebhookMessage<'_>
impl Future for UpdateWebhookMessage<'_> type Output = Result<()>;
[src]Update a message executed by a webhook.
Examples
use twilight_model::id::{MessageId, WebhookId}; client.update_webhook_message(WebhookId(1), "token here", MessageId(2)) .content(Some("new message content".to_owned()))? .await?;
pub fn delete_webhook_message(
&self,
webhook_id: WebhookId,
token: impl Into<String>,
message_id: MessageId
) -> DeleteWebhookMessage<'_>ⓘNotable traits for DeleteWebhookMessage<'_>
impl Future for DeleteWebhookMessage<'_> type Output = Result<()>;
[src]
pub fn delete_webhook_message(
&self,
webhook_id: WebhookId,
token: impl Into<String>,
message_id: MessageId
) -> DeleteWebhookMessage<'_>ⓘNotable traits for DeleteWebhookMessage<'_>
impl Future for DeleteWebhookMessage<'_> type Output = Result<()>;
[src]Delete a message executed by a webhook.
Examples
use twilight_model::id::{MessageId, WebhookId}; client .delete_webhook_message(WebhookId(1), "token here", MessageId(2)) .await?;
pub async fn raw(&self, request: Request) -> Result<Response<Body>>
[src]
pub async fn raw(&self, request: Request) -> Result<Response<Body>>
[src]Execute a request, returning the response.
Errors
Returns Error::Unauthorized
if the configured token has become
invalid due to expiration, revokation, etc.
pub async fn request<T: DeserializeOwned>(&self, request: Request) -> Result<T>
[src]
pub async fn request<T: DeserializeOwned>(&self, request: Request) -> Result<T>
[src]Execute a request, chunking and deserializing the response.
Errors
Returns Error::Unauthorized
if the configured token has become
invalid due to expiration, revokation, etc.
pub async fn verify(&self, request: Request) -> Result<()>
[src]
pub async fn verify(&self, request: Request) -> Result<()>
[src]Execute a request, checking only that the response was a success.
This will not chunk and deserialize the body of the response.
Errors
Returns Error::Unauthorized
if the configured token has become
invalid due to expiration, revokation, etc.
Trait Implementations
impl From<Client<HttpsConnector<HttpConnector<GaiResolver>>, Body>> for Client
[src]
impl From<Client<HttpsConnector<HttpConnector<GaiResolver>>, Body>> for Client
[src]fn from(hyper_client: HyperClient<HttpsConnector<HttpConnector>>) -> Self
[src]
fn from(hyper_client: HyperClient<HttpsConnector<HttpConnector>>) -> Self
[src]Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,