[−][src]Struct twilight_gateway::shard::ShardBuilder
Builder to configure and construct a shard.
Use ShardBuilder::new
to start configuring a new Shard
.
Examples
Create a new shard, setting the large_threshold
to 100 and the
shard
ID to 5 out of 10:
use std::env; use twilight_gateway::{Intents, Shard}; let token = env::var("DISCORD_TOKEN")?; let shard = Shard::builder(token, Intents::GUILD_MESSAGE_REACTIONS) .large_threshold(100)? .shard(5, 10)? .build();
Implementations
impl ShardBuilder
[src]
pub fn new(token: impl Into<String>, intents: Intents) -> Self
[src]
Create a new builder to configure and construct a shard.
Refer to each method to learn their default values.
pub fn build(self) -> Shard
[src]
Consume the builder, constructing a shard.
pub fn gateway_url(self, gateway_url: Option<String>) -> Self
[src]
Set the URL used for connecting to Discord's gateway
pub fn http_client(self, http_client: HttpClient) -> Self
[src]
Set the HTTP client to be used by the shard for getting gateway information.
Default is a new, unconfigured instance of an HTTP client.
pub fn large_threshold(
self,
large_threshold: u64
) -> Result<Self, LargeThresholdError>
[src]
self,
large_threshold: u64
) -> Result<Self, LargeThresholdError>
Set the maximum number of members in a guild to load the member list.
Default value is 250
. The minimum value is 50
and the maximum is
250
.
Examples
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.
Errors
Returns LargeThresholdError::TooFew
if the provided value is below
50.
Returns LargeThresholdError::TooMany
if the provided value is above
250.
pub fn presence(self, presence: UpdateStatusInfo) -> Self
[src]
Set the presence to use automatically when starting a new session.
Default is no presence, which defaults to strictly being "online" with no special qualities.
pub fn queue(self, queue: Arc<Box<dyn Queue>>) -> Self
[src]
Set the queue to use for queueing shard connections.
You probably don't need to set this yourself, because the Cluster
manages that for you. Refer to the queue
module for more
information.
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, ShardIdError>
[src]
self,
shard_id: u64,
shard_total: u64
) -> Result<Self, ShardIdError>
Set 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 250'000 guilds then shard_total
should probably be a multiple of 16 if you're in the "Large Bot
Sharding" program.
Examples
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::{Intents, Shard}; use std::env; let token = env::var("DISCORD_TOKEN")?; let shard = Shard::builder(token, Intents::empty()).shard(18, 19)?.build();
Errors
Returns ShardIdError::IdTooLarge
if the shard ID to connect as is
larger than the total.
Trait Implementations
impl Clone for ShardBuilder
[src]
pub fn clone(&self) -> ShardBuilder
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ShardBuilder
[src]
impl<T: Into<String>> From<(T, Intents)> for ShardBuilder
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ShardBuilder
[src]
impl Send for ShardBuilder
[src]
impl Sync for ShardBuilder
[src]
impl Unpin for ShardBuilder
[src]
impl !UnwindSafe for ShardBuilder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,