[][src]Struct twilight_gateway::shard::config::ShardConfigBuilder

pub struct ShardConfigBuilder(_);

Builder to create a ShardConfig.

Implementations

impl ShardConfigBuilder[src]

pub fn new(token: impl Into<String>) -> Self[src]

Creates a new builder with default configuration values.

Refer to each method to learn their default values.

pub fn build(self) -> ShardConfig[src]

Consumes the builder and returns the final configuration.

pub fn http_client(self, http_client: HttpClient) -> Self[src]

The HTTP client to be used by the shard for getting gateway information.

pub fn intents(&mut self, intents: Option<GatewayIntents>) -> &mut Self[src]

Sets the gateway intents.

pub fn large_threshold(self, large_threshold: u64) -> Result<Self>[src]

The maximum number of members in a guild to load the member list.

If you pass 200, then if there are 250 members in a guild the member list won't be sent. If there are 150 members, then the list will be sent.

The default value is 250. The minimum value is 50 and the maximum is 250.

Errors

Returns Error::LargeThresholdInvalid if the provided value was below 50 or above 250.

pub fn presence(self, presence: UpdateStatusInfo) -> Self[src]

Sets the presence to use automatically when starting a new session.

The default is none, which defaults to strictly being "online" with no special qualities.

pub fn queue(self, queue: Arc<Box<dyn Queue>>) -> Self[src]

Sets the queue to use for queueing shard connections.

You probably don't need to set this yourself, because the Cluster manages that for you. You only need to set this if you're implementing your only cluster-like support.

The default value is a queue used only by this shard, or a queue used by all shards when ran by a Cluster.

pub fn shard(self, shard_id: u64, shard_total: u64) -> Result<Self>[src]

Sets the shard ID to connect as, and the total number of shards used by the bot.

The shard ID is 0-indexed, while the total is 1-indexed.

The default value is a shard ID of 0 and a shard total of 1, which is good for smaller bots.

Note: If your bot is in over 100'000 guilds then shard_total should probably be a multiple of 16 if you're in the "Large Bot Sharding" program.

Errors

If you have 19 shards, then your last shard will have an ID of 18 out of a total of 19 shards:

use twilight_gateway::shard::ShardConfig;
use std::env;

let mut config = ShardConfig::builder(env::var("DISCORD_TOKEN")?);
config.shard(18, 19)?;

Errors

Returns Error::IdTooLarge if the shard ID to connect as is larger than the total.

Trait Implementations

impl Debug for ShardConfigBuilder[src]

impl From<ShardConfigBuilder> for ShardConfig[src]

impl<T: Into<String>> From<T> for ShardConfigBuilder[src]

Auto Trait Implementations

impl !RefUnwindSafe for ShardConfigBuilder

impl Send for ShardConfigBuilder

impl Sync for ShardConfigBuilder

impl Unpin for ShardConfigBuilder

impl !UnwindSafe for ShardConfigBuilder

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, U> Into<U> for T where
    U: From<T>, 
[src]

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<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>,