pub struct RestClient {
pub token: String,
pub base_url: String,
pub http: Client,
/* private fields */
}Expand description
The Main client which is used to interface with the various components of the Discord API.
Fields§
§token: StringThe bot token for this user.
base_url: StringThe base URL of the client. This may be changed to accomodate an external proxy system.
http: ClientImplementations§
Source§impl RestClient
impl RestClient
Sourcepub fn new(token: String, using_ratelimiter: bool) -> Self
pub fn new(token: String, using_ratelimiter: bool) -> Self
Creates a new REST client with the provided configuration. The second argument denotes whether or not to use the built-in rate limiter to rate limit requests to the Discord API. If you plan to use a distributed architecture, you will need an external ratelimiter to ensure ratelimis are kept across servers.
Sourcepub fn set_proxy(self, url: String) -> Self
pub fn set_proxy(self, url: String) -> Self
Enables support for routing all requests though an HTTP rate limiting proxy. If you plan on making distributed REST requests, an HTTP proxy is recommended for handling rate limits in a distributed manner.
Sourcepub fn channel(&self, id: &Snowflake) -> ChannelView
pub fn channel(&self, id: &Snowflake) -> ChannelView
Opens a ChannelView for the provided Channel snowflake.
Sourcepub fn guild(&self, id: &Snowflake) -> GuildView
pub fn guild(&self, id: &Snowflake) -> GuildView
Opens a GuildView for the provided Guild snowflake.
Sourcepub fn webhook(&self, id: &Snowflake) -> WebhookView
pub fn webhook(&self, id: &Snowflake) -> WebhookView
Opens a WebhookView for the provided Webhook snowflake.
Sourcepub fn get_user(
&self,
id: &Snowflake,
) -> impl Future<Item = User, Error = Error>
pub fn get_user( &self, id: &Snowflake, ) -> impl Future<Item = User, Error = Error>
Gets a User object for the provided snowflake.
Sourcepub fn create_dm(
&self,
user: &Snowflake,
) -> impl Future<Item = Channel, Error = Error>
pub fn create_dm( &self, user: &Snowflake, ) -> impl Future<Item = Channel, Error = Error>
Opens a new DM channel with the user at the provided user ID.
Sourcepub fn create_guild(
&self,
opts: CreateGuildOptions,
) -> impl Future<Item = Guild, Error = Error>
pub fn create_guild( &self, opts: CreateGuildOptions, ) -> impl Future<Item = Guild, Error = Error>
Creates a new guild, setting the current client user as owner. This endpoint may only be used for bots who are in less than 10 guilds.
Sourcepub fn leave_guild(
&self,
id: &Snowflake,
) -> impl Future<Item = (), Error = Error>
pub fn leave_guild( &self, id: &Snowflake, ) -> impl Future<Item = (), Error = Error>
Leaves the guild using the provided guild ID.
Sourcepub fn get_voice_regions(
&self,
) -> impl Future<Item = Vec<VoiceRegion>, Error = Error>
pub fn get_voice_regions( &self, ) -> impl Future<Item = Vec<VoiceRegion>, Error = Error>
Modifies properties for the current user. Obtains a list of Discord voice regions.
Sourcepub fn get_invite(
&self,
code: &str,
member_counts: bool,
) -> impl Future<Item = Invite, Error = Error>
pub fn get_invite( &self, code: &str, member_counts: bool, ) -> impl Future<Item = Invite, Error = Error>
Obtains an invite object from Discord using the given code. The second argument denotes whether the invite should contain approximate member counts
Sourcepub fn delete_invite(
&self,
code: &str,
) -> impl Future<Item = Invite, Error = Error>
pub fn delete_invite( &self, code: &str, ) -> impl Future<Item = Invite, Error = Error>
Deletes this invite from the its parent channel.
This requires that the client have the MANAGE_CHANNELS permission.
Trait Implementations§
Source§impl Clone for RestClient
impl Clone for RestClient
Source§fn clone(&self) -> RestClient
fn clone(&self) -> RestClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RestClient
impl !RefUnwindSafe for RestClient
impl Send for RestClient
impl Sync for RestClient
impl Unpin for RestClient
impl !UnwindSafe for RestClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more