[][src]Struct spectacles_rest::RestClient

pub struct RestClient {
    pub token: String,
    pub base_url: String,
    pub http: ReqwestClient,
    // some fields omitted
}

The Main client which is used to interface with the various components of the Discord API.

Fields

token: String

The bot token for this user.

base_url: String

The base URL of the client. This may be changed to accomodate an external proxy system.

http: ReqwestClient

Methods

impl RestClient[src]

pub fn new(token: String, using_ratelimiter: bool) -> Self[src]

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.

pub fn set_proxy(self, url: String) -> Self[src]

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.

pub fn channel(&self, id: &Snowflake) -> ChannelView[src]

Opens a ChannelView for the provided Channel snowflake.

pub fn guild(&self, id: &Snowflake) -> GuildView[src]

Opens a GuildView for the provided Guild snowflake.

pub fn webhook(&self, id: &Snowflake) -> WebhookView[src]

Opens a WebhookView for the provided Webhook snowflake.

pub fn get_user(
    &self,
    id: &Snowflake
) -> impl Future<Item = User, Error = Error>
[src]

Gets a User object for the provided snowflake.

pub fn create_dm(
    &self,
    user: &Snowflake
) -> impl Future<Item = Channel, Error = Error>
[src]

Opens a new DM channel with the user at the provided user ID.

pub fn create_guild(
    &self,
    opts: CreateGuildOptions
) -> impl Future<Item = Guild, Error = Error>
[src]

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.

pub fn leave_guild(
    &self,
    id: &Snowflake
) -> impl Future<Item = (), Error = Error>
[src]

Leaves the guild using the provided guild ID.

pub fn get_voice_regions(
    &self
) -> impl Future<Item = Vec<VoiceRegion>, Error = Error>
[src]

Modifies properties for the current user. Obtains a list of Discord voice regions.

pub fn get_invite(
    &self,
    code: &str,
    member_counts: bool
) -> impl Future<Item = Invite, Error = Error>
[src]

Obtains an invite object from Discord using the given code. The second argument denotes whether the invite should contain approximate member counts

pub fn delete_invite(
    &self,
    code: &str
) -> impl Future<Item = Invite, Error = Error>
[src]

Deletes this invite from the its parent channel. This requires that the client have the MANAGE_CHANNELS permission.

pub fn request<T>(
    &self,
    endpt: Endpoint
) -> Box<dyn Future<Item = T, Error = Error> + Send> where
    T: DeserializeOwned + Send + 'static, 
[src]

Makes an HTTP request to the provided Discord API endpoint. Depending on the ratelimiter status, the request may or may not be rate limited.

pub fn request_empty(
    &self,
    endpt: Endpoint
) -> Box<dyn Future<Item = (), Error = Error> + Send>
[src]

Similar to the above method, but does not attempt to deserialize a JSON payload from the request. Use this method if you are dealing with routes that return 204 (No content).

Trait Implementations

impl Clone for RestClient[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for RestClient[src]

Auto Trait Implementations

impl Send for RestClient

impl Sync for RestClient

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Erased for T

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err