[][src]Struct serenity::client::ClientBuilder

pub struct ClientBuilder<'a> { /* fields omitted */ }

A builder implementing Future building a Client to interact with Discord.

Implementations

impl<'a> ClientBuilder<'a>[src]

pub fn new(token: impl AsRef<str>) -> Self[src]

Construct a new builder to call methods on for the client construction. The token will automatically be prefixed "Bot " if not already.

Panic: If you enabled the framework-feature (on by default), you must specify a framework via the framework or framework_arc method, otherwise awaiting the builder will cause a panic.

pub fn token(self, token: impl AsRef<str>) -> Self[src]

Sets a token for the bot. If the token is not prefixed "Bot ", this method will automatically do so.

pub fn type_map(self, type_map: TypeMap) -> Self[src]

Sets the entire TypeMap that will be available in Contexts. A TypeMap must not be constructed manually: [type_map_insert] can be used to insert one type at a time.

pub fn type_map_insert<T: TypeMapKey>(self, value: T::Value) -> Self[src]

Insert a single value into the internal TypeMap that will be available in Context::data. This method can be called multiple times in order to populate the TypeMap with values.

pub fn cache_update_timeout(self, timeout: Duration) -> Self[src]

Sets how long - if wanted to begin with - a cache update shall be attempted for. After the timeout ran out, the update will be skipped.

By default, a cache update will never timeout and potentially cause a deadlock. A timeout however, will invalidate the cache.

pub fn guild_subscriptions(self, is_enabled: bool) -> Self[src]

Whether presence or typing events shall be received over the gateway.

Info: Prefer to use intents, as this may be replaced by them in the future.**

pub fn framework<F>(self, framework: F) -> Self where
    F: Framework + Send + Sync + 'static, 
[src]

Sets the command framework to be used. It will receive messages sent over the gateway and then consider - based on its settings - whether to dispatch a command.

Info: If a reference to the framework is required for manual dispatch, use the framework_arc-method instead.

pub fn framework_arc(
    self,
    framework: Arc<Box<dyn Framework + Send + Sync + 'static>>
) -> Self
[src]

This method allows to pass an Arc'ed framework - this step is done for you in the framework-method, if you don't need the extra control. You can provide a clone and keep the original to manually dispatch.

pub fn intents(self, intents: GatewayIntents) -> Self[src]

Sets all intents directly, replacing already set intents.

See also: If visually preferred, you can use add_intent and chain it in order to add intent after intent.

Info: Intents are a bitflag, you can combine them by performing the |-operator.

pub fn add_intent(self, intent: GatewayIntents) -> Self[src]

Adds a single intent, this method can be called repetitively to add multiple intents.

See also: If visually preferred, you can use intents and specify all intents at once. In theory you could also achieve the same result by passing the combined intents-bitflag to this method.

pub fn event_handler<H: EventHandler + 'static>(self, event_handler: H) -> Self[src]

Sets an event handler with multiple methods for each possible event.

pub fn raw_event_handler<H: RawEventHandler + 'static>(
    self,
    raw_event_handler: H
) -> Self
[src]

Sets an event handler with a single method where all received gateway events will be dispatched.

Trait Implementations

impl<'a> Future for ClientBuilder<'a>[src]

type Output = Result<Client>

The type of value produced on completion.

Auto Trait Implementations

impl<'a> !RefUnwindSafe for ClientBuilder<'a>

impl<'a> Send for ClientBuilder<'a>

impl<'a> !Sync for ClientBuilder<'a>

impl<'a> Unpin for ClientBuilder<'a>

impl<'a> !UnwindSafe for ClientBuilder<'a>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

impl<T> FutureExt for T where
    T: Future + ?Sized
[src]

impl<T> Instrument for T[src]

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

impl<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<F, T, E> TryFuture for F where
    F: Future<Output = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<Fut> TryFutureExt for Fut where
    Fut: TryFuture + ?Sized
[src]

impl<T, U> TryInto<U> 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<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]