pub struct ConfigBuilder { /* private fields */ }Expand description
Builds a Config. Created by Config::builder.
discord.js counterpart: WebSocketManagerOptions (@discordjs/ws).
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn gateway_url(self, url: impl Into<String>) -> Self
pub fn gateway_url(self, url: impl Into<String>) -> Self
Sets the gateway URL for new sessions (default DEFAULT_GATEWAY_URL).
Use the URL returned by Get Gateway Bot. Resumes always use the resume_gateway_url
from the READY event instead. ws:// URLs are accepted (useful for tests and proxies).
discord.js counterpart: none (@discordjs/ws uses the URL of Get Gateway Bot).
Sourcepub const fn compression(self, compression: Compression) -> Self
pub const fn compression(self, compression: Compression) -> Self
Sets the transport compression (default Compression::ZstdStream when the
zstd-stream feature is enabled).
discord.js counterpart: the compression option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub fn identify_properties(self, properties: IdentifyProperties) -> Self
pub fn identify_properties(self, properties: IdentifyProperties) -> Self
Sets the connection properties sent when identifying (default: library djs-rs).
discord.js counterpart: the identifyProperties option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub const fn large_threshold(self, threshold: u8) -> Self
pub const fn large_threshold(self, threshold: u8) -> Self
Sets the member count (50–250) above which Discord stops sending offline members of a guild (Discord’s default is 50).
discord.js counterpart: the largeThreshold option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub const fn connect_timeout(self, timeout: Duration) -> Self
pub const fn connect_timeout(self, timeout: Duration) -> Self
Sets how long establishing the WebSocket connection (TCP, TLS and upgrade) may take (default 30 s).
discord.js counterpart: the handshakeTimeout option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub const fn hello_timeout(self, timeout: Duration) -> Self
pub const fn hello_timeout(self, timeout: Duration) -> Self
Sets how long to wait for the Hello payload after connecting before reconnecting (default 60 s).
discord.js counterpart: the helloTimeout option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub fn presence(self, presence: UpdatePresence) -> Self
pub fn presence(self, presence: UpdatePresence) -> Self
Sets the presence (status and activities) sent when identifying (default: none, the bot appears online without an activity).
A shard uses it until MessageSender::update_presence
replaces it; that presence is then also kept for later sessions.
discord.js counterpart: the presence client option.
§Examples
use djs_gateway::Config;
use djs_model::gateway::{Activity, Intents, Status, payload::UpdatePresence};
let config = Config::builder("my-token", Intents::GUILDS)
.presence(UpdatePresence::new(Status::Online, [Activity::watching("you")]))
.build();
assert!(config.presence().is_some());Sourcepub fn identify_queue(self, queue: Arc<dyn IdentifyQueue>) -> Self
pub fn identify_queue(self, queue: Arc<dyn IdentifyQueue>) -> Self
Sets the queue shards wait in before identifying (default: a new
LocalIdentifyQueue with max_concurrency 1, shared by clones of the configuration).
Pass a LocalIdentifyQueue created with the bot’s max_concurrency to start several
shards at once, or an own IdentifyQueue to coordinate several processes.
discord.js counterpart: the buildIdentifyThrottler option of WebSocketManagerOptions (@discordjs/ws).
§Examples
use std::sync::Arc;
use djs_gateway::{Config, LocalIdentifyQueue};
use djs_model::gateway::Intents;
let config = Config::builder("my-token", Intents::GUILDS)
.identify_queue(Arc::new(LocalIdentifyQueue::new(16)))
.build();
assert!(format!("{config:?}").contains("max_concurrency: 16"));