pub struct Config { /* private fields */ }Expand description
The configuration of a Shard.
Cheap to clone. Clones share the TLS configuration and the IDENTIFY
queue, so shards created from clones of one configuration
take turns identifying. Build one with Config::builder.
The Debug implementation redacts the token.
discord.js counterpart: WebSocketManagerOptions (@discordjs/ws).
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(token: impl Into<String>, intents: Intents) -> Self
pub fn new(token: impl Into<String>, intents: Intents) -> Self
Creates a configuration with default settings.
Pass the raw token, without the Bot prefix.
discord.js counterpart: new WebSocketManager(options) (@discordjs/ws).
Sourcepub fn builder(token: impl Into<String>, intents: Intents) -> ConfigBuilder
pub fn builder(token: impl Into<String>, intents: Intents) -> ConfigBuilder
Returns a builder to customise the configuration.
discord.js counterpart: WebSocketManagerOptions (@discordjs/ws).
§Examples
use djs_gateway::{Compression, Config};
use djs_model::gateway::Intents;
let config = Config::builder("my-token", Intents::GUILDS | Intents::GUILD_MESSAGES)
.gateway_url("wss://gateway.discord.gg")
.compression(Compression::None)
.large_threshold(250)
.build();
assert_eq!(config.intents(), Intents::GUILDS | Intents::GUILD_MESSAGES);Sourcepub const fn intents(&self) -> Intents
pub const fn intents(&self) -> Intents
Returns the gateway intents.
discord.js counterpart: the intents option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub fn gateway_url(&self) -> &str
pub fn gateway_url(&self) -> &str
Returns the gateway URL used for new sessions.
discord.js counterpart: none (@discordjs/ws uses the URL of Get Gateway Bot).
Sourcepub const fn compression(&self) -> Compression
pub const fn compression(&self) -> Compression
Returns the transport compression.
discord.js counterpart: the compression option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub const fn presence(&self) -> Option<&UpdatePresence>
pub const fn presence(&self) -> Option<&UpdatePresence>
Returns the presence shards using this configuration start with.
discord.js counterpart: the initialPresence option of WebSocketManagerOptions (@discordjs/ws).
Sourcepub fn identify_queue(&self) -> &Arc<dyn IdentifyQueue> ⓘ
pub fn identify_queue(&self) -> &Arc<dyn IdentifyQueue> ⓘ
Returns the queue shards using this configuration wait in before identifying.
discord.js counterpart: the buildIdentifyThrottler option of WebSocketManagerOptions (@discordjs/ws).